【发布时间】:2015-08-01 02:06:43
【问题描述】:
我有这个代码:
import requests
from bs4 import BeautifulSoup
import re
url = "http://www.rockefeller.edu/research/areas/summary.php?id=1"
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
for x in (soup.find_all(string=re.compile('comment'))):
print(x.parent)
print(x.parent.name)
当我听说它应该打印 <a href="/about/comments">Comments</a> 和 a 时,它什么也没打印
我正在使用:
请求:2.7.0
美丽的汤4:4.4.0
Python : 3.4.3
在 python Idle 上运行:Macbook Pro
【问题讨论】:
标签: python-3.x beautifulsoup python-requests