在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/數(shù)據(jù)分析&挖掘/ 如何處理這個顯示更多?

如何處理這個顯示更多?

import urllib.parse
import urllib.request
data={'q':'python'}
params = urllib.parse.urlencode(data)
req = urllib.request.Request("https://www.douban.com/search?{0}".format(params))
response = urllib.request.urlopen(req)
the_page = response.read().decode("utf-8")
with open("/tmp/python.html","w") as f:
     f.write(the_page)

可以獲得這個網(wǎng)頁的檢索結(jié)果,但是,點擊 獲得更多后,還有內(nèi)容。

如何模擬這個點擊更多,將其他的沒有顯示內(nèi)容也抓取出來?

回答
編輯回答
遺莣

分析api,請求接口

2018年8月11日 00:05
編輯回答
久礙你

這個搜索結(jié)果是動態(tài)加載的
實際請求的接口形如下面這樣:

https://www.douban.com/j/search?q=python&start=0&subtype=item
https://www.douban.com/j/search?q=python&start=20&subtype=item
https://www.douban.com/j/search?q=python&start=40&subtype=item

可以看出每次加載20條數(shù)據(jù),點擊加載更多就會調(diào)用下一個請求。
那么可以寫個循環(huán)請求依次取得即可。

2018年9月4日 06:10