import
re
import
requests
url
=
"https://www.dydytt.net/index.htm"
resp
=
requests.get(url, verify
=
False
)
resp.encoding
=
"gb2312"
obj1
=
re.
compile
(r
'<div class="co_content2">.*?<ul>(?P<ul>.*?)</ul>'
, re.S)
obj2
=
re.
compile
(r
"<a href='/html/gndy/dyzz/2021(?P<href>.*?)'"
, re.S)
obj3
=
re.
compile
(r
'◎片 名(?P<name>.*?)<br />.*?<a target="_blank" href="(?P<download>.*?)">'
, re.S)
res1
=
obj1.finditer(resp.text)
sub_list
=
[]
for
r
in
res1:
ul
=
r.group(
'ul'
)
res2
=
obj2.finditer(ul)
for
r2
in
res2:
child_href
=
"https://www.dydytt.net/html/gndy/dyzz/2021"
+
r2.group(
"href"
).strip(
"/"
)
sub_list.append(child_href)
for
href
in
sub_list:
child_resp
=
requests.get(href, verify
=
False
)
child_resp.encoding
=
"gb2312"
res3
=
obj3.search(child_resp.text)
print
(res3.group(
"name"
)
+
" 下載鏈接是: "
+
res3.group(
"download"
)
+
"\n"
)