如何欺骗苹果商店(解析)

时间:2014-09-17 14:01:14

标签: python ios parsing html-parsing python-requests

我正在尝试从苹果商店获取应用信息,但无法完全模仿真实的浏览器:

import requests
headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36'}
# got this user-agent from my own browser where this page opens perfectly though I don't have iTunes installed
store=requests.get('https://itunes.apple.com/en/app/real-racing-3/id556164350', headers=headers)
print store.text

我收到We are unable to find iTunes on your computer.错误,而不是我需要的信息。 希望有一种更好的方法可以不使用Selenium例如

1 个答案:

答案 0 :(得分:1)

好的,我最终想出了这个:

import gtk
import webkit

web = webkit.WebView()
web.open('http://google.com/')


def load_finished(webview, frame):
    data = web.get_main_frame().get_data_source().get_data()
    print data[:20]
    gtk.main_quit()

web.connect("load-finished", load_finished)

gtk.main()