如何使用python在JMP 18中操作硒?我想要自动抓取网页内容,并获取真实的URL。
例如
https://xvfr.com/60s.html
其本质只是一张图片真实的网站https://g.gtimg.cn/music/photo_new/T053XD001001eyb6g4JwXRW.png
页面源代码中没有此图片地址的内容。但是每天都是不同的地址
我在 JMP python 中安装了以下库
jmputils.jpip('install', 'selenium')
jmputils.jpip('install', 'requests')谢谢专家!
基础数据分析与建模视窗回复:如何使用 python 在 JMP 18 中操作硒?如果您需要从图片中获取文本,这就称为 OCR(光学字符识别)。我从来没有玩过它,但看起来 pytesseract 可以处理它;它声称支持多种语言。
回复:如何使用 python 在 JMP 18 中操作硒?我已经解决了图片OCR。

重点是这个图片的地址每天都不一样,我不想手动去获取。
请参阅 Craige Expert 的原始博客。但它太复杂了。我不明白。
所以我想自动获取这个网站的图片真实地址。
谢谢 Craige!
回复:如何使用 python 在 JMP 18 中操作硒?现在想搞清楚怎么结合JMP 18 python来实现每天自动获取这个图片的不同地址来下载并识别JSL。
回复:如何使用 python 在 JMP 18 中操作硒?ChatGPT

我对 python 了解得更少。谢谢!
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time
# Set the path to your ChromeDriver
service = Service(executable_path="path/to/chromedriver")
# Initialize the browser
options = webdriver.ChromeOptions()
options.add_argument('--headless') # Run in headless mode to avoid opening a browser window
browser = webdriver.Chrome(service=service, options=options)
# Visit the target webpage
browser.get("https://xvfr.com/60s.html")
# Wait for the page to load
time.sleep(5) # Wait 5 seconds for the page to load completely; you can use WebDriverWait for better handling
# Get all network requests
logs = browser.get_log('performance')
# Parse network requests to find the image URL
for log in logs:
if 'https://g.gtimg.cn/music/photo_new' in str(log):
print("Found image URL:", str(log))
# Close the browser
browser.quit()