Fetch data from certain div from url

Discussion in 'JavaScript' started by Oberly21, Jan 22, 2021.

  1. #1
    Hi all.
    I have a bit of a struggle here.
    I need to make a simple task to fetch image and then on the new line text from certain div tables from external url.

    I know what div id's are. All i need is to if i change targeted url from the same website and same div table then images and text will change automatically ( as div tables will not change. Just page will change )

    I know it's possible but i don't know where to start actually. Thats why asking you guys.

    I was thinking to start with something like:
    Elements itemprop = doc.select(cssQuery: "div id > div > section id")
    For (Element element : itemprop) {
    System.out.println(element.text());
    }
    Code (JavaScript):
    This would be for example for text i want to pull out. And then image fetch would be something like this..
    Elements img = doc.select( cssQuery: "img");
    For (Element element : img) {
    If (element.toString().contains(".jpg")) {
    Picture1 = element.absUrl (attributeKey: "src").substring(0, element.absUrl( attributeKey: "src");
    Break;
    }
    }
    System.out.println(Picture1);
    
    Code (markup):
    Am i in the right direction? And how i can add to this code the targeted code so it knows from which url to fetch this div table data?
    Hope you will help me.
    Thanks
     
    Oberly21, Jan 22, 2021 IP