# coding=utf-8
from selenium import webdriver
import time
import requests
from bs4 import BeautifulSoup as bs
driver = webdriver.Firefox()
url = "http://china.huanqiu.com/article/2016-07/9132061.html?from=bdwz"
driver.get(url)
response = bs(requests.get(url).content, 'html.parser')
# 获取页面内,h1标签的文章标题
print(u"这篇文章的标题是:", response.h1.string)
# 使用find方法,寻找页面内name=source的content的内容
print (u"这篇文章的类型是:", response.find(attrs={'name': 'source'})['content'])
# 从find_all返回的列表中,查找content字段
for content in response.find_all('meta', {'name': 'source'}):
print(u"这篇文章的类型是:", content['content'])
---------------------
转载,仅作分享,侵删
作者:zhusongziye
原文:https://blog.csdn.net/zhusongziye/article/details/77872108
|
|