Python爬虫基础学习笔记

#python 网络爬虫入门
#网页结构 py 
from urllib import urlopen

html = urlopen("https://morvanzhou.github.io/tutorials/data-manipulation/scraping/").read().decode('utf-8')

print html.format

#使用正则表达式匹配一些html中的关键信息
import re
res = re.findall(r"<title>(.+?)</title>",html)
print res

resref = re.findall(r'href="(.*?)"',html)
print ("\nall links:",res)

#使用beautiful soup简化正则表达式的语法(替代正则表达式)

from bs4 import BeautifulSoup
from urllib import urlopen

猜你喜欢

转载自blog.csdn.net/weixin_39257042/article/details/80457065