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

鍍金池/ 問答/Python/ python 動態(tài)頁面爬取,這個并不是加載更多的動態(tài)頁面,各位看官往下看

python 動態(tài)頁面爬取,這個并不是加載更多的動態(tài)頁面,各位看官往下看

import scrapy
from selenium import webdriver
from text5_Douyu.items import Text5DouyuItem
先貼代碼
import urllib3
class DouyuimageSpider(scrapy.Spider):

name = 'DouyuImage'
#allowed_domains = ['douyu.com']
start_urls = ['https://yuba.douyu.com/allclassify/anchorlist/list/516']
def parse(self, response):
    item=Text5DouyuItem()       
    content=response.xpath("http://div[@clas='classify-classifyGroup-1lMJV']")       
    for list in content:
        nickname=list("./div/p/text()").extract()[0]
        image_href=list("./img/@scr").extract()[0]

        item[nickname]=nicknme
        item[image_href]=image_href

        yield item
        
主要代碼就只有這么點,其他的設(shè)置均正確,只是一個小小的爬蟲,但是爬取的網(wǎng)頁有問題?。。。?這個代碼主要是爬取斗魚上的主播信息,但是代碼寫好以后才發(fā)現(xiàn),扒下來的網(wǎng)頁代碼和在網(wǎng)頁上直接看的代碼是不一樣的,只能說自己是個菜唄,剛知道這也叫動態(tài)網(wǎng)頁。
網(wǎng)頁鏈接如下:[鏈接描述][1]https://yuba.douyu.com/allclassify/anchorlist/list/516
斗魚主播的信息在網(wǎng)頁上按下F12能顯示,但是右鍵“檢查網(wǎng)頁源代碼”就會將主播信息屏蔽了。然后扒下來的代碼也是沒有主播信息的代碼!??!表示沒弄懂要怎樣去扒取這種動態(tài)網(wǎng)頁。
請問這種動態(tài)網(wǎng)頁怎樣爬???是用selenium嗎,反正我是不知道了,請各位不吝賜教,萬分感謝?。。。?!


回答
編輯回答
凹凸曼

clipboard.png

這個是動態(tài)加載的,使用rest api,
使用瀏覽器調(diào)用這個


https://yuba.douyu.com/allclassify/anchorlist/list/516

就已經(jīng)調(diào)用二次動態(tài)rest api

簡單爬取斗魚主播信息代碼


import requests
r = requests.get('https://yuba.douyu.com/wbapi/web/groupRecom/anchor?fid=516&page=1&pagesize=30&timestamp=0.09703142416533206')
print(r.json())
2017年6月24日 09:55