上一篇里面已经有一种方法了,现在再介绍两种
def get_input(html):
data = {}
soup = BeautifulSoup(html, 'html.parser')
inputs = soup.form.findAll('input')
for input in inputs:
if input.get('name'):
data[input.get('name')] = input.get('value')
return data
from lxml import etree
def get_video_url(page_url):
response = requests.get(page_url).text
selector = etree.HTML(response.encode('utf-8'))
x = selector.xpath('//*[@id="player"]/script/text()')
return re.findall('src="(.*?)&', x[0])[0]