1. 程式人生 > >baidu.com關鍵字查詢

baidu.com關鍵字查詢

Coding keyword urlencode agent urlopen div chrome spa .com

# coding:utf-8

import urllib
import urllib2

url = "http://wwww.baidu.com/s"

headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"}


keyword = raw_input("請輸入需要查詢的關鍵字: ")

wd = {"wd" : keyword}


wd = urllib.urlencode(wd)

fullurl 
= url + "?" + wd #print fullurl request = urllib2.Request(fullurl, headers = headers) response = urllib2.urlopen(request) print response.read()

baidu.com關鍵字查詢