| | |
HELP! Return URLs in redirect chain
![]() |
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi,
I'm stuck with a certain problem. I'm using URLLIB2 to get the end url of a list of links. This was pretty straightforward. Some of the links I'm probing pass through 1 or more other urls before landing the user at the end destination.
For example, the start url might be 1, but then you only end up at 3 after a quick and probably unnoticeable redirect to 2:
In my code url 1 is passed to my function, and url 3 is returned, but how do I capture/return any URL in between the start and end points?
Thanks in advance for any help!
LB
I'm stuck with a certain problem. I'm using URLLIB2 to get the end url of a list of links. This was pretty straightforward. Some of the links I'm probing pass through 1 or more other urls before landing the user at the end destination.
For example, the start url might be 1, but then you only end up at 3 after a quick and probably unnoticeable redirect to 2:
Python Syntax (Toggle Plain Text)
1. http://click.someurl.net/script?query=somedata 2. http://bridge.url.net/redirect?url=http://thenewurl.com 3. http://thenewurl.com
In my code url 1 is passed to my function, and url 3 is returned, but how do I capture/return any URL in between the start and end points?
Thanks in advance for any help!
LB
•
•
Join Date: Nov 2009
Posts: 77
Reputation:
Solved Threads: 18
Your post does not provide many details, but I think what you are looking for is a generator function., Instead of returning an URL, yield each URL, like this:
Python Syntax (Toggle Plain Text)
def generateURLs(startingURL): url = startingURL ... while url: yield url url = getNextURL(url) ... for url in generateURLs(http://click.someurl.net/script?query=somedata): print url
"I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum."
------------
This posts may be redistributed under the Creative Commons BY-SA License.
------------
This posts may be redistributed under the Creative Commons BY-SA License.
![]() |
Similar Threads
- I want google to index forum threads (Search Engine Optimization)
- Buy Targeted Traffic, higher ROI (Ad Space for Sale)
- Take part of URL, put into form, post to database. (PHP)
- Complete Makeover - Fear Of Losing Ranking (Search Engine Optimization)
- Page Redirection error (PHP)
- redirect to same filename without extension (Linux Servers and Apache)
- vBulletin mod_rewrite (PHP)
- Need Help (C)
Other Threads in the Python Forum
- Previous Thread: Tasparent window inside a visible frame
- Next Thread: A newbie question of sorts
| Thread Tools | Search this Thread |
301 abrupt address advanced advice anti apax array avogadro backend background beginner bluetooth bmp c++ code content cron curves cx-freeze data desktop development dictionary download dynamic edit enter event examples file filter function generator google gui hints homework htaccess html http image images infosec input ip java jsp keyboard linux list loan loop maze mediawiki microsoft module mod_rewrite movingimageswithpygame newb output programming projects push py2exe pygame pyglet pyqt python random recursive redirect redirecting rubyconf script sessions silverlight simple slicenotation source sqlite ssh stream string sum table terminal tlapse tooltip tricks tutorial ubuntu unicode url urllib urllib2 variable ventrilo wikipedia wxpython






