在python中使用selenium进行web抓取

2024-10-01 19:17:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从这个站点https://loschmidt.chemi.muni.cz/predictsnp2/上抓取数据,但在通过我的代码按下按钮后,从表中获取文本时遇到问题。我不知道我做错了什么,因为这是我第一次做

from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By 
from selenium.webdriver.support.ui import WebDriverWait

driver = 
Webdriver.Firefox(executable_path='D:\\geckodriver\\geckodriver.exe ')
url = "https://loschmidt.chemi.muni.cz/predictsnp2/"
driver . get( url )
s = driver.find_element_by_id ( "isc_3I" )
st="6,1613076,A,T \n1,66075952,G,C \n1,201328373,G,A \n18,48575659,A,G 
    \n3,37067050,A,G"
s1 = driver.find_element_by_id ( 'isc_2S' )
s2 = driver.find_element_by_id ( 'isc_37' )
st1 = 'GRCh38.p1 '
s1 . send_keys ( st1 )
s2 . send_keys ( 'Simple' ) 
s . send_keys ( st )
driver . find_element_by_xpath ( '//div[@id="isc_4B"]' )
time . sleep ( 20 )
print ( driver . find_element_by_xpath ( '//div[@id="isc_4X"]' ) . text )
driver . quit()

C:\Users\kakksfssdsf\PycharmProjects\untitled\venv\Scripts\python.exe C:/Users/kakksfssdsf/PycharmProjects/untitled/test.py

加载文件:

进程已完成,退出代码为0


Tags: fromhttpsimportsendidbydriverselenium

热门问题