import requests
import re
def get_heml_text(url):
try:
kv={"user-agent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'FC%2FuZ9ajQ%3D%3D; mt=ci=-1_0; cookie2=19ea9a18d18256b8f52fdebd099eb842; tb_token=3edea9a6eef73; tk_trace=oTRxOWSBNwn9evfHtXQifmafmYzSU80EW6dedixskcJ%2Bc8J0R27pVpwR009bxUw3pJYMDEOjj9VTZncJdZFFzzCuQZlwGVBOW%2FCRJKJIVtheeX5q%2FaKDT5jdsRLy%2FtFA1krMqbUdMxb6VEc2WIOEGesdZEDO1Rt0GEvS3hI8h7GTBUVPu%2BIFJboYw4NNrv7bRbVBqSBqrQEfO01m29ozFEUt%2F2ao1ZrHWo9p57Vb5VayuVjyN0BTQPieBZhjcOkbm95DfEOYwwDQ1frB39ae1F7TuY474bdH9rMcbmbVL%2Bz1iJVNTPapZbtiC7BBiN1BTZRVz9xfl5yD%2FQT6o%2FnjARRxV2rtTH3vD6hqJlzYZh3h2zxq5vplWojI; _m_h5_tk=43ad03863a5bf153b22ee5c39a678583_1639560939858; _m_h5_tk_enc=571e17d430be51deaed58f1b50c61c38; alitrackid=http://www.taobao.com/; lastalitrackid=http://www.taobao.com/; xlly_s=1; JSESSIONID=35F967F2B978FA61319C1ADC32E4D3CF; uc1=cookie14=Uoe3fokbuHhR6Q%3D%3D; l=eBr51-HrgXir-E2zBOfwnurza77tsIRxIuPzaNbMiOCPOn1p5XsFW6QszuY9CnhVh652R37vCcawBeYBqnY4n5U62j-lasDmn; isg=BIGB_YzIhGkAOOhti8HGAHhYkM2brvWg0kuf7ePWdQjnyqGcK_6gcKrIqT6Mc43Y; tfstk=cMuOBP6uipvM7fFKacKnlQsTBAdhZuJYd1wckB1A3SwV0R_Ai7goyE7yfSOvXBC..'}
r.request.get(url,headers=kv,timeout=30)
r.raise_for_status()
r.encoding= r.apparent_encoding
return r.text
except:
return""
def parsepage(ilt,html):
try:
plt=re.findall(r""view_price":"[\d.]"",html)
tlt=re.findall(r""raw_title":".?"",html)
for i in range(len(plt)):
price=eval(plt[i].split(":")[1])
title=eval(tlt[i].split(":")[1])
ilt.append([price,title])
except:
print("")
def print_goods_list(ilt):
tplt="{:4}\t{:8}\t{:16}"
print(tplt.format("序号","价格","商品名称"))
count=0
for g in ilt:
count=count+1
print(tplt.format(count,g[0],g[1]))
def main():
goods="外套"
depth=2
start_url="https://s.taobao.com/search?initiative_id=tbindexz_20170306&ie=utf8&spm=a21bo.jianhua.20185
结果出来了这个EOL while scanning
string literal是什么意思呀?