-1

How can i extract this from a website?

I know how to do web requests I just cant get my head around the regex pattern.

I want to download a file using a link and that link is in this html code.

<a href="#" onclick="downloadStart();window.location='http://url.co.uk/download/2690'"><button type="submit" class="css3button" value="download">Download</button></a>

This is the url I want http://url.co.uk/download/2690

Thank you any help is very grateful.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563

1 Answers1

0

You can try this regex:

http://url.co.uk/download/[^'"\s]+?(?=['"\s])

This will extract all urls from the page which are the fomat: http://url.co.uk/download/*

Beware that this won't be limited to only anchor tags though.

Pradeep Kumar
  • 6,836
  • 4
  • 21
  • 47