0

I can access a web page from the browser but when accessing it programmaticaly, does not work

i have tried with quote_plus for the #k=#s

urlpage = 'https://www.dnp.gov.co/CONPES/documentos-conpes/Paginas/documentos-conpes.aspx#k=#s=11'
print(urlpage)

html = urlopen(urlpage)
furas
  • 134,197
  • 12
  • 106
  • 148
  • https://stackoverflow.com/a/2146907 – 001 Oct 14 '19 at 02:40
  • Which python version are you using? – san Oct 14 '19 at 02:49
  • what error do you get? always put full error message (starting at word "Traceback") in question (not comment) as text (not screenshot). There are other useful information. – furas Oct 14 '19 at 02:57
  • Python uses different header `User-Agent` than browser and server may recognize it and block your request. Many servers don't like bots/scripts because scripts don't click on ads and server's owners don't get money. Getting data from server (using scripts) can be also treated as stealling. – furas Oct 14 '19 at 03:00
  • Hi. I´m working on python 3.6. I´m using the urlopen because after that i use content = html.read() in order to use scrap a table information that is on table within a CDATA section. My code after that is content = html.read() fileobject = urllib.request.urlopen(urlpage) soup = BeautifulSoup(content) #print(soup) table = soup.find_all('table')[2] #Tabla de datos I´m getting HTTP Error 400: Bad Request. Thanks so much – Oscar Moratto Oct 14 '19 at 11:33

1 Answers1

0

In Python3.x, use webbrowser module to open a weblink in webbrowser from program:

import webbrowser
urlpage = "https://www.dnp.gov.co/CONPES/documentos-conpes/Paginas/documentos-conpes.aspx#k=#s=11"
html = webbrowser.open(urlpage)
san
  • 1,415
  • 8
  • 13