1

I have to import EPF data from itunes Store daily so i have to write a script which will authenticate me firstly through the feeds url and then allow me to download the file automatically through script.

But, i am not finding any way to authenticate myself through url:

http://feeds.itunes.apple.com/feeds/

firstly i downloaded it manually but now i want my script to download it daily. How i can authenticate myself for this? Or there is any other way to achieve this?

Any ideas or view will be highly appreciated.

4

2 に答える 2

1

私はカールを通してそれをしました、そして今私はそれにいます。

$username = "username";
$password = "password";
$url = "http://feeds.itunes.apple.com/feeds/";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;

こんなに簡単でした:)

于 2011-10-10T10:09:39.570 に答える
0

たとえば、 Pythonでは、Authを適切に実行するrequests ライブラリを使用できます(ダウンロードロジックをより簡単な方法で記述できます。次のようになります。

username='yourusernamehere'
password='yourpasswordhere'
response = requests.get('https://feeds.itunes.apple.com/feeds/', auth=(username, password), stream=True)

stream=Trueおそらくメモリに収まらない巨大なファイルをダウンロードするため、このメカニズムを使用したことに注意してください。次のようにチャンクを使用する必要があります。

 with open(local_filename, 'wb') as f:
    for chunk in response.iter_content(chunk_size=1024):
        if chunk:  # filter out keep-alive new chunks
            f.write(chunk)
            f.flush()
于 2015-06-11T17:50:27.667 に答える