求助代码
import urllib2
import re
import os
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0", }
urlcontent = urllib2.urlopen('http://news.qq.com/a/20120506/index.htm')
#print urlcontent
rege = re.compile(r"/a/\d{8}/\d{6}.htm")
get_url = re.findall(rege,urlcontent)
print get_url
exit()
会报错
C:\Users\Min\PycharmProjects\untitled\venv\Scripts\python.exe C:/Users/Min/PycharmProjects/untitled/tcpy2.py
Traceback (most recent call last):
File "C:/Users/Min/PycharmProjects/untitled/tcpy2.py", line 8, in
get_url = re.findall(rege,urlcontent)
File "C:\Users\Min\PycharmProjects\untitled\venv\lib\re.py", line 181, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or buffer
Process finished with exit code 1