当我执行脚本时,结果为空。为什么?该脚本与站点连接并解析 html 标签<a>
:
#!/usr/bin/python3
import re
import socket
import urllib, urllib.error
import http.client
import sys
conn = http.client.HTTPConnection('www.guardaserie.online');
headers = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8" }
params = urllib.parse.urlencode({"s":"hannibal"})
conn.request('GET', '/',params, headers)
response = conn.getresponse();
site = re.search('<a href="(.*)" class="box-link-serie">', str(response.read()), re.M|re.I)
if(site):
print(site.group())