beautifulsoup 获取特定html源码(无需登录页面)

import re
from bs4 import BeautifulSoup
import urllib2

url = 'http://www.cnblogs.com/vickey-wu/'
# connect to a URL
web = urllib2.urlopen(url)
# read html code
html = web.read()
# print html
soup = BeautifulSoup(html,'html.parser')
prety = soup.prettify()
# print prety
pointed_div = soup.findAll(name="div", attrs={"class":re.compile("forFlow")})    # 筛选标签为div且属性class为forFlow的源码
print pointed_div

相关文章:

  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-02-11
猜你喜欢
  • 2022-12-23
  • 2021-11-27
  • 2021-12-28
  • 2021-11-27
  • 2021-11-28
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案