马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import requests
from lxml import etree
import csv
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.ui import WebDriverWait
import requests
import base64
import selenium.webdriver.support.expected_conditions as EC
import datetime
import urllib.request
import re
import os
import PyPDF2
from PyPDF2 import PdfFileReader
from bs4 import BeautifulSoup
import io
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
s = requests.Session()
fb = webdriver.FirefoxProfile.DEFAULT_PREFERENCES
# op = webdriver.FirefoxOptions()
# op.set_preference({'user-data-dir':''})
c = webdriver.ChromeOptions()
c.add_argument('--user-data-dir=D:/AutomationProfile')
c.add_argument('--headless')
# c.add_argument(f'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36')
driver = webdriver.Chrome()
driver.get('https://www.jiaoyifamen.com/variety/research-report')
time.sleep(5)
driver.find_element(By.XPATH, '//div[text()="中粮期货-玉米日报20230110"]').click()
time.sleep(3)
我想要实现:点击含有“玉米”的链接。能够使用正则表达的方式实现吗?(设想中的是:driver.find_element(By.XPATH, '//div[text()="(.*)玉米(.*)"]').click()
) |