如何从列表中获取base.php?id = 5314?正则表达式在Python中查找列表中的字符串3
import urllib.parse
import urllib.request
from bs4 import BeautifulSoup
url = 'http://www.fansubs.ru/search.php'
values = {'Content-Type:' : 'application/x-www-form-urlencoded',
'query' : 'Boku dake ga Inai Machi' }
d = {}
data = urllib.parse.urlencode(values)
data = data.encode('ascii')
req = urllib.request.Request(url, data)
with urllib.request.urlopen(req) as response:
the_page = response.read()
soup = BeautifulSoup(the_page, 'html.parser')
for link in soup.findAll('a'):
d[link] = (link.get('href'))
x = (list(d.values()))
什么是你的问题是什么呢? – Arman
这是我的理解,他正在调查页面中的所有'a's,并且想要过滤特定的'href'值...(作为列表存储在'x'中) – urban