Jump to content

How to extract from html source code


newcoder1010
 Share

Recommended Posts

Hello,

HTML source code:

https://www.walmart.com/ip/Parent-s-Choice-Diapers-Size-3-36-Diapers/14912811

If you view html source code, you will see the upc code. 

"standardusItemId":"401199665","upc":"681131167444","fetched":true,

 

I like to write a program to just print the code(value only).

 
 String str = driver.getPageSource();
            System.out.println("-----");

            System.out.println(str);
            System.out.println("field" + str.indexOf("upc"));
            
            System.out.println("value" + str.indexOf("681131167444"));

Result:

index1033185
upc603459

I know code is not complete. My code gets the page source just fine. Only extracting the code is not working. Please advise!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...