def main():
total = search()
for i in total:
total = int(re.compile('(\d)').search(total).group(1))
print(i.text)
出错:
Traceback (most recent call last):
File "F:/untitled/venv/Scripts/Crawler.py", line 33, in <module>
main()
File "F:/untitled/venv/Scripts/Crawler.py", line 28, in main
total = (re.compile('(\d)').search(total).group(1), str(total))
TypeError: expected string or bytes-like object
不知道怎么改,试了很多方法都没用
def main():
url = '...'
total = get_search(url)
total = int(re.compile('(\d+)').search(total).group(1))
print("抓取到{}页信息".format(total))
已经解决了,谢谢,虽然答案并不是采用你的。(抱歉没把整个代码贴出来,也许并不适用我那个)
没把真个代码贴出来,抱歉