Chicocvenancio added a comment.
In T230135#5403134 <https://phabricator.wikimedia.org/T230135#5403134>, @OlafJanssen wrote: > @Chicocvenancio Thanks for elegant your solution. I looked at https://stackoverflow.com/questions/10606133/sending-user-agent-using-requests-library-in-python > I added this the notebook, is that a valid approach as well? (I'm not experienced with this sort of stuff yet) > > -------------------------------------------- > > import requests > url = 'http://www.kb.nl' > headers = { > > 'User-Agent': 'My User Agent 1.0', > 'From': '[email protected]' # This is another valid field > > } > response = requests.get(url, headers=headers) That won't change the UserAgent used by SPARQLWrapper. SPARQLWrapper has an `agent` parameter you can use that will solve this. ... def get_results(endpoint_url, query): sparql = SPARQLWrapper(endpoint_url, agent='OlafJanssen from PAWS') ... Is one way to get this working. TASK DETAIL https://phabricator.wikimedia.org/T230135 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Chicocvenancio Cc: Lucas_Werkmeister_WMDE, Chicocvenancio, OlafJanssen, darthmon_wmde, 94rain, DannyS712, Nandana, Lahi, Gq86, R96340, GoranSMilovanovic, Allthingsgo, QZanden, EBjune, merbst, LawExplorer, Framawiki, _jensen, rosalieper, Jonas, Xmlizer, Jane023, jkroll, Smalyshev, Wikidata-bugs, Jdouglas, Xqt, aude, Tobias1984, yuvipanda, Capt_Swing, Manybubbles, zhuyifei1999, Mbch331
_______________________________________________ Wikidata-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs
