user2009020
user2009020

Reputation: 287

Specifying redirect page to clicked link

I'm writing a script in python, using mechanize. I'm following a link:

br = mechanize.Browser()
br.open("http://www.neopets.com/browseshop.phtml?owner=nick_291540") 
#returns last link
for link in br.links(url_regex="buy_item.phtml"):
    placeholder = 1

br.follow_link(link)

I want to pretend that I'm being directed to the link from a certain url. How do I do this?

Upvotes: 1

Views: 39

Answers (1)

alecxe
alecxe

Reputation: 473863

You can set Referer header, example from docs:

import mechanize
req = mechanize.Request("http://foobar.com/")
req.add_header("Referer", "http://wwwsearch.sourceforge.net/mechanize/")
r = mechanize.urlopen(req)

Upvotes: 2

Related Questions