欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

如何用python查京東圖書

林玟書2年前15瀏覽0評論

如何用python查京東圖書?

import requests

from bs4 import BeautifulSoup

from fake_useragent import UserAgent

#京東圖書信息抓取

def getImg(isbn):

url = 'https://search.jd.com/Search?keyword='+isbn+'&enc=utf-8&pvid=ce5ca7fd71e34233be029f688ac48bce'

ua = UserAgent()

headers = {'User-Agent':ua.random}

data = requests.get(url, headers=headers)

data.encoding = 'utf-8' #亂碼轉碼

#print(data.text)

soup = BeautifulSoup(data.text,'lxml')

img_div = soup.find_all('div',{'class':'p-img'})

#print(len(img_div))

imgs = []

for index in range(len(img_div)):

imgs.append('http:'+img_div[index].find('img').get('source-data-lazy-img'))

return imgs

if __name__=='__main__':

print('京東圖書信息抓取開始。。。')

imgs = getImg('9787533735609')

print(imgs)

print('京東網圖書信息抓取結束。。。')