小编Bha*_*ara的帖子

使用 selenium python 复制文本区域

我想使用硒从文本框中复制所有值。到目前为止我的代码看起来像

# -*- coding: UTF-8 -*
from selenium import webdriver    #open webdriver for specific browser
import requests
import time

def getListZip(zip,radius):
    browser = webdriver.Chrome()
    browser.get("https://www.freemaptools.com/find-zip-codes-inside-radius.htm")
    time.sleep(10)
    user = browser.find_element_by_css_selector("#tb_radiuskm")
    user.clear()
    user.send_keys(radius)
    user = browser.find_element_by_css_selector("#goto")
    user.clear()
    user.send_keys(zip)
    time.sleep(10)
    drawRadius = browser.find_element_by_css_selector("#contenttext > center:nth-child(8) > input:nth-child(1)")
    drawRadius.click()
    time.sleep(10)
    listZip= browser.find_element_by_xpath('//*[@id="tb_output"]').text
    return listZip

def main():
    zip = getListZip(43212,25)

if __name__ == "__main__":
    main()    
Run Code Online (Sandbox Code Playgroud)

这应该返回近 70 个值,但它返回 null。该程序将以邮政编码和半径形式提供输入,并将获得特定半径内所有邮政编码的输出。

我正在使用 python 3.x

python selenium web-scraping

2
推荐指数
1
解决办法
2556
查看次数

标签 统计

python ×1

selenium ×1

web-scraping ×1