
python网络数据采集笔记
bwcxljsm
这个作者很懒,什么都没留下…
展开
-
python——Beautifulsoup
网络爬虫可以通过class属性的值,轻松地区分出<span class="green"></span>,<span class="red"></span>两种不同的标签。可以将网页的红色文字抓取而绿色的一个都不抓。例如网站:战争与和平代码:from urllib.request import urlopen from bs4 import Beaut...原创 2018-03-14 20:50:31 · 189 阅读 · 0 评论 -
网络数据采集——导航树
以网站http://www.pythonscraping.com/pages/page3.html为例。<html> <head> <style> img{ width:75px; } table{ width:50%; } td{ margin:10px; padding:10px; } .wrapper{ width:800px; } .excit...原创 2018-03-15 19:53:43 · 394 阅读 · 0 评论 -
网络数据采集——BeautifulSoup与正则表达式
from urllib.request import urlopen from bs4 import BeautifulSoup import re html = urlopen("http://www.pythonscraping.com/pages/page3.html") bsObj = BeautifulSoup(html) images = bsObj.findAll("img",{"s...原创 2018-03-17 14:25:09 · 1617 阅读 · 0 评论 -
网络数据采集——遍历单个域名
from urllib.request import urlopen from bs4 import BeautifulSoup import datetime import random import re random.seed(datetime.datetime.now()) def getLinks(articleUrl): html=urlopen("http://en.wi...原创 2018-03-19 15:41:06 · 646 阅读 · 0 评论 -
网络数据采集——收集整个网站
from urllib.request import urlopen from bs4 import BeautifulSoup import re pages=set()#避免存入相同的链接 def getlinks(pageUrl): global pages html=urlopen("http://en.wikipedia.org"+pageUrl) bsOb...原创 2018-03-19 16:17:01 · 2057 阅读 · 0 评论