python - 我已经连上了美国的VPN,而且在浏览器里查看的game排行也是美国的,可是为啥我用代码怎么爬都是中国地区排行
天蓬老师
天蓬老师 2017-04-18 10:34:59
0
2
1069

-encoding:utf-8--
import requests, xlwt, sys
from bs4 import BeautifulSoup

reload(sys)
sys.setdefaultencoding('utf-8')
header = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
}

def main():

url = 'https://play.google.com/store/apps/category/GAME/collection/topselling_free?hl=zh-TW'
data = {
        'start': '0',
        'num' : '100',

}
a = []
b = []
req = requests.post(url,headers = header,data = data).content
soup = BeautifulSoup(req,'html.parser')
titles = soup.find_all('p',{'class':'details'})
for title in titles :
    name = title.find('a',{'class':'title'}).get('title')
    host_url = title.find('a',{'class':'title'}).get('href')
    print name , host_url
    a.append(name)
    b.append(host_url)

for i in range(len(a)):
    sheet.write(i,0,a[i])
for n in range(len(b)):
    sheet.write(n,1,b[n])

if name == '__main__':

wb = xlwt.Workbook()
sheet = wb.add_sheet("top_100")
main()
wb.save('gametop100.xls')
# login()
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全員に返信(2)
小葫芦

サーバーはリクエストの最終的な送信元を検出できるので、プロキシを設定しても問題ありません
または、より深いプロキシが必要です

いいねを押す +0
大家讲道理

クローラーはプロキシを設定していませんか?

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!