Git Product home page Git Product logo

gsmarena-scraper's Introduction

gsmarena_scraper

DEPRECATED: even with tor, the rate limiting of gsmarena is too sensitive for the script to complete properly. Use it at your own risk.

This script extract the mobile specs from all the phones available in gsmarena.com to a csv file (+ one for each brand).

To avoid spam detection, run with TOR (see below).

Requirements

  • python + pip
  • docker + docker-compose

Installation

Clone the repository:

git clone https://github.com/dbeley/gsmarena-scraper
cd gsmarena-scraper

Install the python dependencies:

pip install requests beautifulsoup4 lxml pandas pysocks stem

If you prefer, you can also install the requirements in a virtual environment with pipenv (in order to run the python script, you will need to use pipenv run python gsmarena-scraper.py instead of python gsmarena-scraper.py):

pipenv install

Usage

Run the docker container containing the tor proxy (you can tweak the torrc configuration file if you want, but the defaults should be good):

docker-compose up -d

Run the script:

python gsmarena-scraper.py

After completion, you can stop the docker container with docker-compose down.

Help

python gsmarena_scraper.py -h
usage: gsmarena-scraper.py [-h] [--debug]

Scraper gsmarena.

optional arguments:
  -h, --help  show this help message and exit
  --debug     Display debugging information

Files exported

The exported files will be placed in a folder named Exports. The all-brands_exports.csv will contain the data of all brands.

gsmarena-scraper's People

Contributors

aqidd avatar dbeley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gsmarena-scraper's Issues

Too many request

Its showing me too many request when I run the script.
File "gsmarena-scraper.py", line 32 logger.info(f"Too many requests.") ^ SyntaxError: invalid syntax

How can I solve this?

save each brand to csv file while scraping others

hi. it would be good to save each brand into csv file when finishes and starts scraping another brand. otherwise remote host blocks requests:

Traceback (most recent call last):
File "C:\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen
chunked=chunked)
File "C:\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "C:\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 843, in validate_conn
conn.connect()
File "C:\Python37-32\lib\site-packages\urllib3\connection.py", line 370, in connect
ssl_context=context)
File "C:\Python37-32\lib\site-packages\urllib3\util\ssl
.py", line 355, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Python37-32\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Python37-32\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Python37-32\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python37-32\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Python37-32\lib\site-packages\urllib3\util\retry.py", line 368, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Python37-32\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen
chunked=chunked)
File "C:\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "C:\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 843, in validate_conn
conn.connect()
File "C:\Python37-32\lib\site-packages\urllib3\connection.py", line 370, in connect
ssl_context=context)
File "C:\Python37-32\lib\site-packages\urllib3\util\ssl
.py", line 355, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Python37-32\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Python37-32\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Python37-32\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Users\XXX.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\ptvsd_launcher.py", line 43, in
main(ptvsdArgs)
File "c:\Users\XXX.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\lib\python\ptvsd_main_.py", line 432, in main
run()
File "c:\Users\XXX.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\lib\python\ptvsd_main_.py", line 316, in run_file
runpy.run_path(target, run_name='main')
File "C:\Python37-32\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Python37-32\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\XXX\Desktop\gsmarena-scraper-master\gsmarena-scraper.py", line 192, in
main()
File "c:\Users\XXX\Desktop\gsmarena-scraper-master\gsmarena-scraper.py", line 59, in main
File "C:\Python37-32\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Python37-32\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python37-32\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python37-32\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Python37-32\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Addition of the "battery-test" information

Hi,

great tool.

It is so sad, that gsmarena does not offer a good way to retrieve the information that people really need... .

My approach to find a new phone is presently:

  1. look at https://www.gsmarena.com/battery-test.php3 for the phones with the longest runtime.
  2. find manually those that are not too big, have fm-radio etc.

It would be very cool if this scraper would also retrieve the (available) data from https://www.gsmarena.com/battery-test.php3 and add it to the referring phones as extra column(s).

Thanks for taking this into consideration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.