Content-Length: 215830 | pFad | https://github.com/fake-useragent/fake-useragent/commit/cf2fb19c635dd302414bd7cd8f4a733baf60ad01

A5 Be a bit more robust for generic version strings. · fake-useragent/fake-useragent@cf2fb19 · GitHub
Skip to content

Commit

Permalink
Be a bit more robust for generic version strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 committed Oct 2, 2023
1 parent 7194943 commit cf2fb19
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cache_scraper/useragentscraper/spiders/useragent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,24 @@ def parse(self, response):

for agent in agents:
try:
[browser, version, os] = agent["system"].split()
system_splitted = agent["system"].split()
if len(system_splitted) > 3:
[browser, version, os] = agent["system"].split()
else:
[browser, version, os] = agent["system"].split()
# Remove percentage icon & convert to float
agent["percent"] = float(agent["percent"][:-1])
# Add additional fields
agent["browser"] = browser.lower() # To lower-case
agent["version"] = float(version) # Convert to float
# If version equals Generic, just set version to: 1.0
if version == "Generic":
agent["version"] = 1.0
else:
agent["version"] = float(version) # Convert to float
agent["os"] = os.lower() # To lower-case
# Yield each agent object at the time
yield agent
except ValueError:
except ValueError as e:
# Ignore user-agent strings that could not be parsed (eg. bot agent strings)
# (eg. bot agent strings like headless chrome, but also Yandex Browser and iOS)
pass

0 comments on commit cf2fb19

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/fake-useragent/fake-useragent/commit/cf2fb19c635dd302414bd7cd8f4a733baf60ad01

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy