1

I try to read out the string inside of an unordered list .

The string of interest is the following number: href="?notation=1549220" image

I am very new to HTML/CSS/JavaScript so please excuse this simple question.

I tried something like this, but it's getting nowhere:

document.getElementById('exchangesLayerHs')
  .getElementsByTagName('ul')
  .getElementsByTagName('li')
  .getElementsByTagName('a');

Has anyone a tipp for me?

Thanks a lot! Carlo

1
  • I think it would be very helpful if you posted your entire AppleScript rather than just the JavaScript snippet Commented Jul 30, 2017 at 0:55

1 Answer 1

1

You could get the link with the title handelsplatz geschlossen :

var link = document.querySelector("a [title='Handelsplatz geschlossen']");

Now simply get the thing behind = in the href and convert it to a number (+) :

var result = + link.href.split("=")[1];
Sign up to request clarification or add additional context in comments.

4 Comments

Hi Jonas, thanks for your quick response! I tried to include your proposal into my applescript as follows: set link to do JavaScript "document.querySelector('a [title='Handelsplatz geschlossen']');" in document 1 But when I try to log link then I get an error message "'link' is not defined". What do I do wrong?
@carloP i cant help you with apple script... Sorry
By the way, the tag <a> with title="Handelsplatz geschlossen" is not unique, there are multiple of these tags in the unordered list <ul>. Is this the reason why I maybe could not reach it just by the title?
@carloP then you need querySelectorAll(...)[4] to get e.g. the fourth one. However, the error you get is related to applescript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.