小编Ale*_*oup的帖子

Selenium webdriver能否在发送密钥之间随机抽出时间(以便在输入时模拟人类行为)?

我正在使用selenium webdriver来完成一个表单,但是想要在键入时模拟人类行为而不是自动填充我的值.

例如:

driver.find_element_by_id("Address").send_keys("Anthony Street 35th")
Run Code Online (Sandbox Code Playgroud)

我想在输入安东尼街时模拟人类行为,每次击键之间随机时间暂停.

可以这样做吗?

python selenium python-2.7

4
推荐指数
1
解决办法
2070
查看次数

使用BeautifulSoup从span类中提取锚文本

这是我试图抓取的HTML:

<span class="meta-attributes__attr-tags">
<a href="/tags/cinematic" title="cinematic">cinematic</a>, 
<a href="/tags/dissolve" title="dissolve">dissolve</a>,
<a href="/tags/epic" title="epic">epic</a>,
<a href="/tags/fly" title="fly">fly</a>,
</span>
Run Code Online (Sandbox Code Playgroud)

我想得到每个href的锚文本:电影,溶解,史诗等.

这是我的代码:

url = urllib2.urlopen("http: example.com")

content = url.read()
soup = BeautifulSoup(content)

links = soup.find_all("span", {"class": "meta-attributes__attr-tags"})
for link in links:
    print link.find_all('a')['href']
Run Code Online (Sandbox Code Playgroud)

如果我用"link.find_all"来做,我得到错误:TypeError:List索引必须是整数,而不是str.

但是,如果我打印link.find('a')['href']我只得到第一个.

我怎样才能得到所有这些?

python beautifulsoup scrape

4
推荐指数
1
解决办法
2454
查看次数

标签 统计

python ×2

beautifulsoup ×1

python-2.7 ×1

scrape ×1

selenium ×1