淘宝图片正则提取不到
pat = '"pic_url":"//(.*?)"'imglist = re.compile(pat).findall(data)
淘宝图片爬虫利用这个无法找到任何东西,求教怎么才可以得到数据?? 这是什么鬼,搞个你写的具体代码 发出来看看 用代码块贴出你的代码 附上代码
import urllib.request
import re
import random
keyname="python"
uapools=[
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393",
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.22 Safari/537.36 SE 2.X MetaSr 1.0",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)",
]
def ua(uapools):
thisua=random.choice(uapools)
print(thisua)
headers=("User-Agent",thisua)
opener=urllib.request.build_opener()
opener.addheaders=
urllib.request.install_opener(opener)
for i in range(1,101):
url="https://s.taobao.com/search?q="+keyname+"&s="+str((i-1)*44)
ua(uapools)
data=urllib.request.urlopen(url).read().decode("utf-8","ignore")
pat='"pic_url":"//(.*?)"'
imglist=re.compile(pat).findall(data)
print(imglist)
页:
[1]