Drew, Mario is using SPARQLWrapper - https://sparqlwrapper.readthedocs.io - not just RDFLib.
Mario: it would indeed be wonderful if you could add a small writeup of this to https://sparqlwrapper.readthedocs.io/en/latest/main.html#python-package / https://github.com/RDFLib/sparqlwrapper/blob/master/README.rst (the README comes through to ReadTheDocs docco too). After the RDFLib 8.0.0 major release in the next few months, we'll put the call out for updates to a range of RDFLib-related packaged and SPARQLWrapper is one of those. It's working fine but could do with a lot of improvements, especially given more modern HTTP libraries like requests / httpx. Cheers, Nick On Wednesday, 27 November 2024 at 07:45, Drew Perttula <dr...@bigasterisk.com> wrote: > Thanks for posting the solution. Can you also share what doc links you > originally looked at? Then we can add some text to help the next user with > the same problem. > > The closest I can find is > https://rdflib.readthedocs.io/en/stable/intro_to_sparql.html#querying-a-remote-service > but that doesn't look like what you were using. As for what to link to, > perhaps https://docs.python.org/3.5/howto/urllib2.html#proxies would help, > though it doesn't list all the > > On 11/26/24 03:42, Mario Migliaccio wrote: > >> The error is: >> >> urllib.error.HTTPError: HTTP Error 403: Forbidden >> >> I solved it using this piece of code when raising this error >> >> import urllib.request HTTP_PROXIES = { >> 'http': f'http://{PROXY_USER}:{PROXY_PASSWORD}@' >> f'{PROXY_HOST}:{PROXY_PORT}','https': f'https: >> //{PROXY_USER}:{PROXY_PASSWORD}@' f'{PROXY_HOST}:{PROXY_PORT}' ',} >> proxy_support = urllib.request.ProxyHandler(HTTP_PROXIES) >> opener = urllib.request.build_opener(proxy_support) >> urllib.request.install_opener(opener) >> >> and then >> >> results = sparql.query().convert() >> I think this solved my issue allowing using proxy to make a call thought >> SparqlWrapper >> >> On Tuesday, 26 November 2024 at 08:25:18 UTC+1 carlo...@gmail.com wrote: >> >>> Hi Mario, >>> >>> could you share the error returned? >>> >>> Best, >>> >>> Carlos >>> On Friday, November 22, 2024 at 5:10:38 PM UTC+1 Mario Migliaccio wrote: >>> >>>> Just to give an example I'm using this code to query data from official >>>> endpoint from Italian assembly. I am having trouble with the connection of >>>> my production environment. I am wondering if it is possibile to query >>>> through a proxy I have >>>> having >>>> PROXY_PORT >>>> PROXY_HOST >>>> PROXY_PASSWORD >>>> PROXY_USER >>>> >>>> sparql_endpoint = "https://dati.senato.it/sparql" >>>> sparql = SPARQLWrapper(sparql_endpoint) >>>> sparql.setQuery("""PREFIX osr: <http://dati.senato.it/osr/> >>>> PREFIX foaf: <http://xmlns.com/foaf/0.1/> >>>> >>>> SELECT DISTINCT ?senatore ?nome ?cognome ?inizioMandato ?legislatura >>>> ?tipoMandato >>>> WHERE { >>>> ?senatore a osr:Senatore. >>>> ?senatore foaf:firstName ?nome. >>>> ?senatore foaf:lastName ?cognome. >>>> ?senatore osr:mandato ?mandato. >>>> ?mandato osr:legislatura ?legislatura. >>>> ?mandato osr:inizio ?inizioMandato. >>>> ?mandato osr:tipoMandato ?tipoMandato. >>>> OPTIONAL { ?mandato osr:fine ?df. } >>>> FILTER(!bound(?df)) >>>> } ORDER BY ?cognome ?nome >>>> """) >>>> sparql.setReturnFormat(JSON) >>>> sparql.setTimeout(10) sparql.query().convert() >>>> On Friday, 22 November 2024 at 17:06:07 UTC+1 Mario Migliaccio wrote: >>>> >>>>> I am wondering if there's the possibility to query the endpoint throgh a >>>>> proxy. >>>>> >>>>> Is it possibile? >> >> -- >> http://github.com/RDFLib >> --- >> You received this message because you are subscribed to the Google Groups >> "rdflib-dev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rdflib-dev+unsubscr...@googlegroups.com. >> To view this discussion visit >> https://groups.google.com/d/msgid/rdflib-dev/1d03b6af-e9e0-4b76-8027-89ac39f82ca5n%40googlegroups.com. > > -- > http://github.com/RDFLib > --- > You received this message because you are subscribed to the Google Groups > "rdflib-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rdflib-dev+unsubscr...@googlegroups.com. > To view this discussion visit > https://groups.google.com/d/msgid/rdflib-dev/e8198a79-25b5-438d-8582-1173547d1cf8%40bigasterisk.com. -- http://github.com/RDFLib --- You received this message because you are subscribed to the Google Groups "rdflib-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/rdflib-dev/4oAoWPOMtODNy1i_fpmKIdaVNP7htHLmyOimXo9RUdWz9WqO8qMzt_uQZLTVsjH3szTkec3kvlskynh17qsWM1uH0909TsW6mBM2cytQW0o%3D%40kurrawong.net.