Jump to content

how to get a value(string) from an external page ?


kejo

Recommended Posts

thank you so much.

i love this forum. really helpful.

 

anyway im trying to understand what this string means:

('/<span id="download-count"[^>]*>[^0-9]*([0-9]+)/'

 

i dont know the regex :\

so now that im "adapting " your script to my personal needs, i have to edit it (the actual url is not the one i posted)

Link to comment
Share on other sites

sasa how come the script you wrote takes time to load?

other pages are faster than this one.

is there a faster method?

thanks

 

You can always use a method of cacheing the number every day so while it may not be as UP TO DATE on a second-by-second basis, it'll be reasonably close.

 

By this, I mean calling the page, saving the number in a flat file on your server that you can access readily and display the number.

Link to comment
Share on other sites

ok thanks

im learning much more thanks to you guys.

anyway im still trying to understand the regex.

 

[^>] = looks for all text except the <

[^0-9] = looks for all non numeric characters

*([0-9]+) = ???

what about the last?

 

thanks mates you rock!

Link to comment
Share on other sites

ok thanks

im learning much more thanks to you guys.

anyway im still trying to understand the regex.

 

[^>] = looks for all text except the <

[^0-9] = looks for all non numeric characters

*([0-9]+) = ???

what about the last?

 

thanks mates you rock!

 

('/<span id="download-count"[^>]*>[^0-9]*([0-9]+)/'

 

Ok, you are right about the first two.. Except it looks like this:

 

[^>]*

>

[^0-9]*

([0-9]+)

 

If you broke it into separate entities. It goes through the string until it hits a ">" hence the looks for all text except the >. Then, it reads off the ">", goes through all NON-NUMERIC stuff until it hits the numbers. Then, it saves (or "remembers") at least one or more numbers from this point.

 

a * after the set means 0 or more times.

a + after the set means 1 or more times.

 

Check this link for quick references if you need help :-)

 

http://www.quanetic.com/regex.php

Link to comment
Share on other sites

[^>] = looks for all text except the <

[^0-9] = looks for all non numeric characters

*([0-9]+) = ???

what about the last?

 

The first is correct, except it's >.

 

The second is incorrect because you're not pairing the quantifier. Quantifiers determine how much of something is matched, and always follow what they affect. Therefore, the second part is [^0-9]*, which matches anything that is not a digit zero or more times.

 

The third part, without the leading quantifier, captures any digits that appear one or more times.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.