python爬虫笔记(五)网络爬虫之提取—信息组织与提取方法(2)信息提取的一般方法

1. 信息提取的一般方法

1.1 方法一

1.2 方法2

1.3 方法3

2. 实例

import requests
from bs4 import BeautifulSoup

r = requests.get("http://python123.io/ws/demo.html")

demo = r.text

print(demo, "\n")

soup = BeautifulSoup(demo, "html.parser")

for link in soup.find_all('a'):
    print(link.get('href'))

猜你喜欢

转载自www.cnblogs.com/douzujun/p/12241099.html