title_node = soup.find('dd',class_='lemmaWgt-lemmaTitle-title').find('h1')
title_data = title_node.get_text()
title_data = title_node.get_text()
2018-05-18
最新回答 / 慕粉1224386790
URL 需要先确定。必须是能够正常打开的网址(URL),比如 www.hao123.com 和 www.baidu.com 之类的都可以。
2018-05-15
print('获取P')
pnode = soup.find_all('p', class_ = 'title')
for link in pnode:
print(link.name, link.get_text)
pnode = soup.find_all('p', class_ = 'title')
for link in pnode:
print(link.name, link.get_text)
2018-05-11
print('获取Lacie的链接')
link_node = soup.find_all('a', href = 'http://example.come/Lacie')
for link in link_node:
print(link.name, link['href'], link.get_text() )
print('正则匹配')
link_node = soup.find_all( 'a', href = re.compile(r"ill") )
for link in link_node:
link_node = soup.find_all('a', href = 'http://example.come/Lacie')
for link in link_node:
print(link.name, link['href'], link.get_text() )
print('正则匹配')
link_node = soup.find_all( 'a', href = re.compile(r"ill") )
for link in link_node:
2018-05-11
# coding = gbk
from bs4 import BeautifulSoup
import re
'''
'''
soup = BeautifulSoup(html_doc, 'html.parser')
print('获取所有的链接:')
links = soup.find_all('a')
for link in links:
print( link.name, link['href'], link.get_text() )
from bs4 import BeautifulSoup
import re
'''
'''
soup = BeautifulSoup(html_doc, 'html.parser')
print('获取所有的链接:')
links = soup.find_all('a')
for link in links:
print( link.name, link['href'], link.get_text() )
2018-05-11
最赞回答 / 小图兔
在Python3中我们用urllib.requet 代替urllib2看你的代码应该是Python3,其中包含了request方法,所以结果第一行返回结果一样的话,程序会认为你下面的request是你上面第一行的返回,所以出错。
2018-05-08