Skip to content

Commit 12ac43a

Browse files
Initial commit
1 parent 0021943 commit 12ac43a

File tree

10 files changed

+169
-2
lines changed

10 files changed

+169
-2
lines changed

.github/workflows/main.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: lint-test-publish
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Install dependencies
11+
run: |
12+
make deps
13+
- name: Lint code
14+
run: |
15+
make lint
16+
test:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
python-version: ['3.6', '3.7', '3.8']
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set up Python
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
make deps
30+
publish:
31+
needs: [lint, test]
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Install dependencies
36+
run: |
37+
make deps
38+
- name: Build package
39+
run: >-
40+
make build
41+
- name: Publish package to Test PyPI (always)
42+
uses: pypa/gh-action-pypi-publish@release/v1
43+
with:
44+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
45+
repository_url: https://test.pypi.org/legacy/
46+
skip_existing: true
47+
- name: Publish package to PyPI (only if pushing a tag)
48+
if: startsWith(github.ref, 'refs/tags')
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
with:
51+
password: ${{ secrets.PYPI_API_TOKEN }}

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
install: ## Install package from source in edit mode
2+
pip install -e .
3+
4+
deps: ## Install development dependencies
5+
pip install -r requirements.txt
6+
7+
lint: ## Lint code
8+
flake8 --config flake8 google_maps_api/ setup.py
9+
10+
build: ## Build a binary wheel and a source tarball
11+
python setup.py sdist bdist_wheel

README.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
1-
# google-maps-api-python
2-
Real-Time Google Maps API
1+
# Google Maps API
2+
[Scrapeit Cloud](https://scrape-it.cloud/) - Web Scraping API with Proxy Rotation. Get valuable data at scale in HTML format from any website without need for a proxy.
3+
4+
Interface to call [Google Maps Scraper](https://scrape-it.cloud/google-maps-scraper) easily from Python.
5+
6+
## Install
7+
8+
pip install sc-google-maps-api
9+
10+
## Usage
11+
Signup to Scrapeit Cloud to [get your API key](https://app.scrape-it.cloud/sign-up) and some free credits to get started.
12+
13+
>>> from sc_google_maps_api import ScrapeitCloudClient
14+
>>>
15+
>>> client = ScrapeitCloudClient(api_key='INSERT_YOUR_API_KEY_HERE')
16+
>>>
17+
>>> response = client.scrape(
18+
params={
19+
"keyword": "plumber in new york",
20+
"page": 1,
21+
"country": "US",
22+
"domain": "com"
23+
}
24+
)
25+
>>>
26+
>>> response.text
27+
'{"status":"ok","scrapingResult":{"pagination":{"currentPage":1,"nextPage":2},"locals":[{"position":1,"title":"Hub Plumbing & Mechanical","phone":"+1 917-634-8888","address":"103 Charles St, New York, NY 10014, United States","website":"http://www.hubplumbingnyc.com/","rating":4.6,"reviews":53,"type":"Plumber"},{"position":2,"title":"Rite Plumbing & Heating","phone":"+1 347-502-6441","address":"750 Lexington Ave 9th Floor, New York, NY 10022, United States","website":"http://www.riteplumbingnyc.com/","rating":4.3,"reviews":37,"type":"Plumber"},{"position":3,"title":"RR Plumbing Roto-Rooter","phone":"+1 212-687-1215","address":"450 7th Ave Ste B, New York, NY 10123, United States","website":"https://www.rotorooter.com/manhattan/","rating":4.7,"reviews":702,"type":"Plumber"},{"position":4,"title":"Plumbing NYC","phone":"+1 347-973-9186","address":"510 W 45th St apt 11g, New York, NY 10036, United States","website":"https://plumbingnyc.com/","rating":4.9,"reviews":48,"type":"Plumber"},{"position":5,"title":"Plumber New York","phone":"+1 646-604-0862","address":"134 W 28th St, New York, NY 10001, United States","website":"null","rating":4.9,"reviews":48,"type":"Plumber"},{"position":6,"title":"WaterHouse Plumbing Company","phone":"+1 212-777-3003","address":"171 Attorney St, New York, NY 10002, United States","website":"https://waterhouse.nyc/","rating":4.4,"reviews":14,"type":"Plumber"},{"position":7,"title":"Emergency Plumbing Solutions","phone":"+1 646-374-3144","address":"106 W 19th St, New York, NY 10011, United States","website":"null","rating":5,"reviews":43,"type":"Plumber"},{"position":8,"title":"Near Plumber CO","phone":"+1 646-736-6681","address":"7 Waverly Pl, New York, NY 10003, United States","website":"null","rating":4.9,"reviews":47,"type":"Plumber"},{"position":9,"title":"Emergency Plumb CO","phone":"+1 646-736-6297","address":"398 Broome St, New York, NY 10013, United States","website":"null","rating":5,"reviews":45,"type":"Plumber"},{"position":10,"title":"Manhattan Sewer Drain","phone":"+1 212-641-0256","address":null,"website":"http://www.manhattansewerdrain.com/","rating":4.9,"reviews":28,"type":"Plumber"},{"position":11,"title":"L & R Plumbing","phone":"+1 646-760-3415","address":"491 3rd Ave, New York, NY 10016, United States","website":"null","rating":5,"reviews":29,"type":"Plumber"},{"position":12,"title":"The Pump Guys LLC. Pump & Motor Specialist","phone":"+1 212-239-1094","address":"1177 6th Ave 5th floor, New York, NY 10036, United States","website":"https://thepumpguys.solutions/","rating":5,"reviews":42,"type":"Plumber"},{"position":13,"title":"Super Plumbers Heating and Air Conditioning","phone":"+1 201-345-5128","address":null,"website":"https://superplumbersnj.com/services/nj/hudson-county/hoboken/","rating":4.6,"reviews":92,"type":"Plumber"},{"position":14,"title":"24 Hour Plumber NYC","phone":"+1 646-693-6598","address":"101 Lexington Ave, New York, NY 10016, United States","website":"http://24hourplumber.nyc/","rating":4.4,"reviews":13,"type":"Plumber"},{"position":15,"title":"Neo Plumbing & Heating Corp Plumber service in Manhattan","phone":"+1 646-860-0149","address":"10 E 39th St Suite 909, Manhattan, NY 10016, United States","website":"https://neoplumbingnyc.com/","rating":5,"reviews":14,"type":"Plumber"},{"position":16,"title":"New York Drain Restoration inc","phone":"+1 212-693-7246","address":"225 W 12th St, New York, NY 10011, United States","website":"null","rating":4.7,"reviews":16,"type":"Plumber"},{"position":17,"title":"X Y T Plumbing & Heating Chelsea","phone":"+1 646-588-0266","address":"125 W 33rd St, New York, NY 10001, United States","website":"null","rating":5,"reviews":12,"type":"Plumber"},{"position":18,"title":"24 HR Emergency Plumber NYC INC","phone":"+1 866-219-9182","address":null,"website":"https://24hremergencyplumber.info/nyc/","rating":5,"reviews":45,"type":"Plumber"},{"position":19,"title":"Super Sewer Man","phone":"+1 212-799-1605","address":"3 Little W 12th St, New York, NY 10014, United States","website":"null","rating":5,"reviews":15,"type":"Plumber"},{"position":20,"title":"Tri Star Plumbing & Heating Inc","phone":"+1 212-925-0006","address":null,"website":"null","rating":5,"reviews":7,"type":"Plumber"}]}}'
28+
>>>
29+
30+
You can find all the supported parameters on [Scrapeit Cloud documentation](https://scrape-it.cloud/docs/).

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
flake8==3.9.2
2+
pytest==5.4.2
3+
tox==3.23.1
4+
wheel==0.36.2

sc_google_maps_api/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__all__ = ['ScrapeitCloudClient']
2+
3+
from sc_google_maps_api.client import ScrapeitCloudClient

sc_google_maps_api/__version__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '1.0.2'

sc_google_maps_api/client.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from requests import request, Response
2+
3+
from .default_headers import default_headers
4+
5+
6+
class ScrapeitCloudClient:
7+
api_url = "https://api.scrape-it.cloud/scrape/google/locals"
8+
9+
def __init__(self, api_key: str):
10+
self.api_key = api_key
11+
12+
def scrape(
13+
self,
14+
params: dict,
15+
**kwargs
16+
) -> Response:
17+
headers = {
18+
"x-api-key": self.api_key
19+
}
20+
21+
headers.update(default_headers)
22+
23+
return request("POST", self.api_url, data=params, headers=headers, **kwargs)

sc_google_maps_api/default_headers.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .__version__ import __version__
2+
3+
# Add User-Agent identifying sdk
4+
default_headers = {"User-Agent": f"ScrapeitCloud-Python/{__version__}"}

setup.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import os
2+
3+
from setuptools import setup
4+
5+
about = {}
6+
here = os.path.abspath(os.path.dirname(__file__))
7+
with open(os.path.join(here, 'sc_google_maps_api', '__version__.py'), 'r', encoding='utf-8') as f:
8+
exec(f.read(), about)
9+
10+
setup(
11+
name='sc-google-maps-api',
12+
version=about['__version__'],
13+
url='https://github.com/Scrapeit-Cloud/google-maps-api-python',
14+
description='Real-Time Google Maps API',
15+
long_description=open('README.md').read(),
16+
long_description_content_type='text/markdown',
17+
author='Roman Milyushkevich',
18+
author_email='[email protected]',
19+
maintainer='Roman Milyushkevich',
20+
maintainer_email='[email protected]',
21+
license='MIT',
22+
packages=['sc_google_maps_api'],
23+
classifiers=[
24+
'License :: OSI Approved :: MIT License',
25+
'Programming Language :: Python',
26+
'Programming Language :: Python :: 3',
27+
'Programming Language :: Python :: 3.6',
28+
'Programming Language :: Python :: 3.7',
29+
'Programming Language :: Python :: 3.8',
30+
'Topic :: Software Development :: Libraries :: Python Modules',
31+
],
32+
python_requires='>=3.6',
33+
install_requires=['requests'],
34+
)

tox.ini

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[tox]
2+
envlist = py36,py37,py38
3+
4+
[testenv]
5+
allowlist_externals = make
6+
deps = pytest
7+
commands =
8+
make test

0 commit comments

Comments
 (0)