【发布时间】:2018-10-04 09:13:56
【问题描述】:
我正在为 Upwork.com 制作一个机器人,所以我想获得 Upwork 帖子的“发布时间”,如下所示
但是当我得到一个文本时它返回一个 None 值
我正在使用此代码:
from urllib.request import Request, urlopen
req = Request('https://www.upwork.com/o/jobs/browse/?q=scrap', headers={'User-Agent': 'Mozilla/5.0'})
html = urlopen(req).read()
soup = beautifulsoup(html)
for all_items in soup.select('.job-tile'):
Time=all_items.select_one('time').text
print(Time)
输出:
None
当我通过 BeautifulSoup 获得 HTML 时,我注意到 HTML 不包含在文本中,如下面的 HTML 所示:
<span class="js-posted">Posted
<time data-eo-relative="2018-04-24T06:11:41+00:00" datetime="2018-0424T06:11:41+00:00" itemprop="datePosted"> </time>
</span>
谁能告诉我为什么文本没有在 HTML 中显示?为什么我得到 None 值而不是文本存在?
注意:我在窗口 10 上使用 python 3.6.5
【问题讨论】:
标签: python web-scraping automation beautifulsoup bots