jenkins-bot has submitted this change and it was merged.
Change subject: Use new get_fake_user_agent function for User-agent ......................................................................
Use new get_fake_user_agent function for User-agent
Bug: T71204 Change-Id: I9a55897a4065920305bd5ef46930252fa429e63d --- M scripts/weblinkchecker.py 1 file changed, 3 insertions(+), 7 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py index 89a1b6b..d1f0834 100755 --- a/scripts/weblinkchecker.py +++ b/scripts/weblinkchecker.py @@ -122,7 +122,7 @@
import pywikibot
-from pywikibot import i18n, config, pagegenerators, textlib, weblib +from pywikibot import comms, i18n, config, pagegenerators, textlib, weblib
from pywikibot.bot import ExistingPageBot, SingleSiteBot from pywikibot.pagegenerators import ( @@ -292,15 +292,11 @@ redirectChain is a list of redirects which were resolved by resolveRedirect(). This is needed to detect redirect loops. """ + self._user_agent = comms.http.get_fake_user_agent() self.url = url self.serverEncoding = serverEncoding self.header = { - # 'User-agent': pywikibot.useragent, - # we fake being Firefox because some webservers block unknown - # clients, e.g. https://images.google.de/images?q=Albit gives a 403 - # when using the Pywikibot user agent. - 'User-agent': 'Mozilla/5.0 (X11; U; Linux i686; de; rv:1.8) ' - 'Gecko/20051128 SUSE/1.5-0.1 Firefox/1.5', + 'User-agent': self._user_agent, 'Accept': 'text/xml,application/xml,application/xhtml+xml,' 'text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'Accept-Language': 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3',