我希望提取网页上呈现的数据的某些部分.我可以从页面中提取整个数据,并使用下面的代码将其保存在文本文件(RAW)中.
curl http://webpage -o "raw.txt"
Run Code Online (Sandbox Code Playgroud)
只是想知道是否还有其他选择和优势.
我会使用请求和BeautifulSoup的组合.
import requests
import BeautifulSoup
session = requests.session()
req = session.get('http://stackoverflow.com/questions/10807081/script-to-extract-data-from-wbpage')
doc = BeautifulSoup.BeautifulSoup(req.content)
print doc.findAll('a', { "class" : "gp-share" })
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
60089 次 |
| 最近记录: |