Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
pim97 committed Jun 20, 2023
0 parents commit c5a9a7a
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Demon Martin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
78 changes: 78 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 🤖 Scrappey Wrapper - Data Extraction Made Easy

Introducing Scrappey, your comprehensive website scraping solution provided by Scrappey.com. With Scrappey's powerful and user-friendly API, you can effortlessly retrieve data from websites, including those protected by Cloudflare. Join Scrappey today and revolutionize your data extraction process. 🚀

**Disclaimer: Please ensure that your web scraping activities comply with the website's terms of service and legal regulations. Scrappey is not responsible for any misuse or unethical use of the library. Use it responsibly and respect the website's policies.**

Website: https://scrappey.com/

## Topics

- [Installation](#installation)
- [Usage](#usage)
- [Example](#example)
- [License](#license)

## Installation

Use pip to install the Scrappey library. 💻

```shell
pip install scrappey
```

## Usage

Import the Scrappey library in your code. 📦

```python
import scrappey
```

Create an instance of Scrappey by providing your Scrappey API key. 🔑

```python
api_key = 'YOUR_API_KEY'
scrappey_instance = scrappey.Scrappey(api_key)
```

### Example

Here's an example of how to use Scrappey. 🚀

```python
from scrappey import Scrappey

scrappey = Scrappey('YOUR_API_KEY')

def run_test():
try:
session = scrappey.create_session()
print(session)

get_request_result = scrappey.get_request('https://reqres.in/api/users', session['session'])
print('GET Request Result:', get_request_result)

post_data = {'username': 'user123', 'password': 'pass456'}
post_request_result = scrappey.post_request('https://reqres.in/api/users', post_data, session['session'])
print('POST Request Result:', post_request_result)

scrappey.destroy_session(session['session'])
print('Session destroyed.')
except Exception as error:
print(error)

run_test()
```

For more information, please visit the [official Scrappey documentation](https://wiki.scrappey.com/getting-started). 📚

## License

This project is licensed under the MIT License.

## Additional Tags

cloudflare anti bot bypass, cloudflare solver, scraper, scraping, cloudflare scraper, cloudflare turnstile solver, turnstile solver, data extraction, web scraping, website scraping, data scraping, scraping tool, API scraping, scraping solution, web data extraction, website data extraction, web scraping library, website scraping library, cloudflare bypass, scraping API, web scraping API, cloudflare protection, data scraping tool, scraping service, cloudflare challenge solver, web scraping solution, web scraping service, cloudflare scraping, cloudflare bot protection, scraping framework, scraping library, cloudflare bypass tool, cloudflare anti-bot, cloudflare protection bypass, cloudflare solver tool, web scraping tool, data extraction library, website scraping tool, cloudflare turnstile bypass, cloudflare anti-bot solver, turnstile solver tool, cloudflare scraping solution, website data scraper, cloudflare challenge bypass, web scraping framework, cloudflare challenge solver tool, web data scraping, data scraper, scraping data from websites, SEO, data mining,

data harvesting, data crawling, web scraping software, website scraping tool, web scraping framework, data extraction tool, web data scraper, data scraping service, scraping automation, scraping tutorial, scraping code, scraping techniques, scraping best practices, scraping scripts, scraping tutorial, scraping examples, scraping challenges, scraping tricks, scraping tips, scraping tricks, scraping strategies, scraping methods, cloudflare protection bypass, cloudflare security bypass, web scraping Python, web scraping JavaScript, web scraping PHP, web scraping Ruby, web scraping Java, web scraping C#, web scraping Node.js, web scraping BeautifulSoup, web scraping Selenium, web scraping Scrapy, web scraping Puppeteer, web scraping requests, web scraping headless browser, web scraping dynamic content, web scraping AJAX, web scraping pagination, web scraping authentication, web scraping cookies, web scraping session management, web scraping data parsing, web scraping data cleaning, web scraping data analysis, web scraping data visualization, web scraping legal issues, web scraping ethics, web scraping compliance, web scraping regulations, web scraping IP blocking, web scraping anti-scraping measures, web scraping proxy, web scraping CAPTCHA solving, web scraping IP rotation, web scraping rate limiting, web scraping data privacy, web scraping consent, web scraping terms of service, web scraping robots.txt, web scraping data storage, web scraping database integration, web scraping data integration, web scraping API integration, web scraping data export, web scraping data processing, web scraping data transformation, web scraping data enrichment, web scraping data validation, web scraping error handling, web scraping scalability, web scraping performance optimization, web scraping distributed scraping, web scraping cloud-based scraping, web scraping serverless scraping.
56 changes: 56 additions & 0 deletions scrappey.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import requests

class Scrappey:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = 'https://publisher.scrappey.com/api/v1'

def send_request(self, endpoint, method, data=None):
url = f'{self.base_url}?key={self.api_key}'

headers = {
'Content-Type': 'application/json'
}

payload = {
'cmd': endpoint,
**data
}

try:
response = requests.request(method, url, headers=headers, json=payload)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as error:
raise error

def create_session(self, session_id=None, proxy=None):
return self.send_request('sessions.create', 'POST', {'session': session_id, 'proxy': proxy})

def destroy_session(self, session_id):
if session_id is None:
raise ValueError('sessionId parameter is required.')

return self.send_request('sessions.destroy', 'POST', {'session': session_id})

def get_request(self, url, session_id=None, cookiejar=None, proxy=None):
if url is None:
raise ValueError('url parameter is required.')

if session_id is None and cookiejar is None and proxy is None:
raise ValueError('At least one of sessionId, cookiejar, or proxy parameters must be provided.')

return self.send_request('request.get', 'POST', {'url': url, 'session': session_id, 'cookiejar': cookiejar, 'proxy': proxy})

def post_request(self, url, post_data, session_id=None, cookiejar=None, proxy=None):
is_form_data = isinstance(post_data, str) and '=' in post_data

if not is_form_data:
try:
request_data = requests.utils.quote(post_data)
except ValueError:
raise ValueError('Invalid postData format. It must be in application/x-www-form-urlencoded format.')
else:
request_data = post_data

return self.send_request('request.post', 'POST', {'url': url, 'postData': request_data, 'session': session_id, 'cookiejar': cookiejar, 'proxy': proxy})
22 changes: 22 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from scrappey import Scrappey

scrappey = Scrappey('YOUR_API_KEY')

def run_test():
try:
session = scrappey.create_session()
print(session)

get_request_result = scrappey.get_request('https://reqres.in/api/users', session['session'])
print('GET Request Result:', get_request_result)

post_data = {'username': 'user123', 'password': 'pass456'}
post_request_result = scrappey.post_request('https://reqres.in/api/users', post_data, session['session'])
print('POST Request Result:', post_request_result)

scrappey.destroy_session(session['session'])
print('Session destroyed.')
except Exception as error:
print(error)

run_test()

0 comments on commit c5a9a7a

Please sign in to comment.