web scraping - Getting mobile version of a web page instead of the desktop version with selenium webdriver -


I Debian'm using headless Firefox on a remote server in order to get some data scrap with selenium Vebdrivr and later Skapere Be close Instead of getting the desktop version, I'm getting the mobile version of the web page from which I'm trying to scrape data. I need the desktop version! I think I need to send the proper user agent string and I how to do it:

  def call_via_proxy (PROXY_HOST, PROXY_PORT): fp = webdriver.FirefoxProfile () # Direct = 0; manual = 1, PAC = 2, Otodetekt = 4, system = 5 fp.set_preference ( "network.proxy.type", 1) fp.set_preference ( "network.proxy.http", Proksi_host) fp.set_preference ( "network. proxy. Http_port ", int (PROXY_PORT)) fp.set_preference (" general.useragent.override "," Mozilla / 5.0 (Windows NT 6.1; WOW64; rv: 31.0) Gecko / 20100101 Firefox / 31.0 ") fp.update_preferences () Return Webdriver Firefox (Firefox_Prop I = FP) #create webdriver driver = call_via_proxy ("us.proxymesh.com", "31280") driver.get (response.url)  

The code works fine on my desktop machine (Win7) but on the server (Debian) where the code needs to be run I am getting a mobile version of the web page. Even if I use the Phantom's S, then the same is PhantomJS user_agent = ("Mozilla / 5.0 (Macintosh; Intel Mac OS X L0_8_4) # user agents #set for ") dcap = dict (desitionalCapabilities.PHANTOMJS) dcap [" phantomjs.page.settings .userAgent "] = user_agent driver = webdriver.PhantomJS ( '/ usr / local / share / phantomjs-1.9.7-linux-i686 / bina / phantomjs', Wanchit_kapshn = dcap) driver.get (response.url)

what HTTP response code to a web page with selenium Is there any way to get it? I wonder what is wrong here? I do not believe that there is something to do with dependence on the platform? Any advice?

I have this problem with some mobile responsive templates that go by the size of the screen. In this example, the phantom appears to be my own set of rules for desktop browser size ( driver.manage (. Code.wall.size) ) starts working for me.

I do not have a Java code for this, but in C # this would be:

  _driver.Manage (). Window size = new size (1024768);  

I remember that there is a dimension value that you can pass instead I do this and the desktop page comes once again!


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -