i can get the content with urllib2.Request(website, data=None, headers = headers), but I cannot ...

22 views
Skip to first unread message

zhouya...@139.com

unread,
May 1, 2015, 12:46:57 AM5/1/15
to seleniu...@googlegroups.com
i can get the content with urllib2.Request(website, data=None, headers = headers), but I cannot open the website by selenium with below scripts(
    from selenium import webdriver
    myff = webdriver.Firefox()
    myff.add_cookie(headers)
    myff.get(website)

)
********************************************
here , the headers ={

        'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Encoding':'gzip, deflate',
        'Accept-Language':'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3',
        'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0',
        'Cookie':'_gscu_993197171=28403458i885b418; JSESSIONIDwljg=0000Nj_Thmz0a9Yvn6mdL4ApfRf:16vfceu36',
        'Referer':'anotherwebsite',
        'Connection':'keep-alive',
        'Host':'website'}
for security reason, I replace the real website by website here.
********************************************
I used the Fiddler to see what happened:
1) In urllib2, see all key and values
2) in selenium, see {
        'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Encoding':'gzip, deflate',
        'Accept-Language':'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3',
        'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0',
        'Connection':'keep-alive',
        'Host':'website'}, the Cookies and Referer haven't been seen in Fiddler log

Why?


murali seleniumtrainer

unread,
May 1, 2015, 12:03:47 PM5/1/15
to seleniu...@googlegroups.com
Hi,

Are you able to open the firefox browser?

In java, some time's i faced like opening browser but not able to navigate to URL as my firefox is updated and jar is old..

Thanks,
http://seleniumtrainer.com/
Reply all
Reply to author
Forward
0 new messages