import requests
import re
domain = "https://www.dytt8.net/index.htm"
try:
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3870.400 QQBrowser/10.8.4405.400"
}
resp = requests.get(domain, headers = headers)
resp.raise_for_status()
resp.encoding = resp.apparent_encoding
except:
print("F")
obj = re.compile(r"2021新片精品.*?<ul>(?P<film>.*?)</ul>", re.S)
obj1 = re.compile(r"<a href='(?P<href>.*?)'", re.S)
obj2 = re.compile(r'◎片 名 (?P<movie_name>.*?)<br />.*?<a target="_blank" href="(?P<download>.*?)">', r.S)
result1 = obj.finditer(resp.text)
child_href = []
for it in result1:
ul = it.group('film')
出现以下报错:
Traceback (most recent call last):
File "D:\python\工程\pythonProject\re 进入子页面获取.py", line 24, in
obj2 = re.compile(r'◎片 名 (?P.?)
.?
', r.S)NameError: name 'r' is not defined
https://ask.csdn.net/(?P%3Cdownload%3E.*?)
Process finished with exit code 1
why?求解答
https://ask.csdn.net/(?P%3Cdownload%3E.*?)