對于https需要做以下處理
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
response = urllib.request.urlopen(url)
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
response = urllib.request.urlopen(url)
2018-04-04
print("正則匹配")
link_node = soup.find('a', href = re.compile(r"ill"))
print(link_node.name, link_node['href'], link_node.get_text())
link_node = soup.find('a', href = re.compile(r"ill"))
print(link_node.name, link_node['href'], link_node.get_text())
2018-04-04
print("獲取lacie的鏈接")
link_node = soup.find('a', href = 'http://example.com/lacie')
print(link_node.name, link_node['href'], link_node.get_text())
link_node = soup.find('a', href = 'http://example.com/lacie')
print(link_node.name, link_node['href'], link_node.get_text())
2018-04-04
soup = BeautifulSoup(html_doc,'html.parser',from_encoding='utf-8')
print("獲取所有的鏈接")
links = soup.find_all('a')
for link in links:
print(link.name , link['href'],link.get_text())
print("獲取所有的鏈接")
links = soup.find_all('a')
for link in links:
print(link.name , link['href'],link.get_text())
2018-04-04
如果安裝了pip 直接在cmd中輸入 pip install BeautifulSoup4 。幾秒就成功了。
2018-03-31
亂碼 添加
fout.write('<meta charset="utf-8">')
fout.write('<meta charset="utf-8">')
2018-03-27
python2可以運行流暢,希望能給你們提供點幫助,帶注釋
https://github.com/aiyuan-haohao/Python_potato
https://github.com/aiyuan-haohao/Python_potato
2018-03-27