cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Due to global connectivity issues impacting AWS Services, users may experience unexpected errors while attempting to authorize JMP. Please try again later or contact support@jmp.com to be notified once all issues are resolved.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lala
Level IX

How can use python to manipulate selenium in JMP 18?

I want to automatically capture the content of the web page and get the real URL.

For example the

https://xvfr.com/60s.html 

its essence is only a picture real website https://g.gtimg.cn/music/photo_new/T053XD001001eyb6g4JwXRW.png 

 

There is no content for this image address in the page source code.But it's a different address every day

 

I have installed the following libraries in JMP python

jmputils.jpip('install', 'selenium')
jmputils.jpip('install', 'requests')

Thanks Experts!

 

4 REPLIES 4
Craige_Hales
Super User

Re: How can use python to manipulate selenium in JMP 18?

if you need to get text from a picture, that's called OCR (optical character recognition.) I've never played with it, but it looks like pytesseract might handle it; it claims to support many languages.

Craige
lala
Level IX

Re: How can use python to manipulate selenium in JMP 18?

I have solved the picture OCR.

2024-09-03_11-19-32.png

 

The point is that the address of this picture is different every day and I don't want to get it manually.

See Craige Expert's original blog.But it's too complicated. I don't understand.

So I want to automatically get the real address of the picture for this website.

 

Thank Craige!

lala
Level IX

Re: How can use python to manipulate selenium in JMP 18?

Now I want to figure out how to combine JMP 18 python to automatically get a different address of this image every day to download and recognize JSL.

lala
Level IX

Re: How can use python to manipulate selenium in JMP 18?

ChatGPT

2024-09-04_10-33-46.png

I know even less about python.Thanks!

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()

Recommended Articles