xkcd: account for Bing search returning mobile URLs #2247
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Yeah,
.xkcd
search hasn't been working very well because Bing decided to start returningm.xkcd.com
URLs much of the time.Interestingly, adding
-site:m.xkcd.com
made Bing return NO results, not the normal (non-mobile) link. That's why this patch modifies the regex to validate the result instead.I'm not sure what's up with the optional protocol prefix, but didn't want to touch it in a patch intended for stable branch.
Effect
Checklist
make qa
(runsmake quality
andmake test
)Notes
Back in November I tried to fix this on the
search
plugin side with a few never-submitted tweaks that didn't actually help reliably. This solution is so stupid-simple… 😅Along the way I considered trying to make the search more robust by pulling in results from both
sopel.modules.search.bing_search()
andsopel.modules.search.duck_search()
, but that's probably overkill.