Skip to content

Commit

Permalink
post request fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pim97 committed Jun 20, 2023
1 parent e5b4dbd commit 093da34
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 6 deletions.
Binary file removed dist/scrappeycom-0.3.2.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion scrappeycom.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: scrappeycom
Version: 0.3.2
Version: 0.3.3
Summary: An API wrapper for Scrappey.com written in Python (cloudflare bypass & solver)
Home-page: https://github.com/pim97/scrappey-wrapper-python
Download-URL: https://github.com/pim97/scrappey-wrapper-python/releases/tag/v_03
Expand Down
1 change: 1 addition & 0 deletions scrappeycom.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
requests
urllib
Binary file added scrappeycom/__pycache__/scrappey.cpython-311.pyc
Binary file not shown.
5 changes: 3 additions & 2 deletions scrappeycom/scrappey.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import requests
import urllib.parse

class Scrappey:
def __init__(self, api_key):
Expand Down Expand Up @@ -47,10 +48,10 @@ def post_request(self, url, post_data, session_id=None, cookiejar=None, proxy=No

if not is_form_data:
try:
request_data = requests.utils.quote(post_data)
request_data = urllib.parse.urlencode(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})
return self.send_request('request.post', 'POST', {'url': url, 'postData': request_data, 'session': session_id, 'cookiejar': cookiejar, 'proxy': proxy})
4 changes: 2 additions & 2 deletions scrappeycom/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def run_test():
session = scrappey.create_session()
print(session)

get_request_result = scrappey.get_request('https://reqres.in/api/users', session['session'])
get_request_result = scrappey.get_request('https://httpbin.rs/get', 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'])
post_request_result = scrappey.post_request('https://httpbin.rs/post', post_data, session['session'])
print('POST Request Result:', post_request_result)

scrappey.destroy_session(session['session'])
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
name = 'scrappeycom', # How you named your package folder (MyLib)
packages = ['scrappeycom'], # Chose the same as "name"
version = '0.3.2', # Start with a small number and increase it with every change you make
version = '0.3.3', # Start with a small number and increase it with every change you make
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
description = 'An API wrapper for Scrappey.com written in Python (cloudflare bypass & solver)', # Give a short description about your library
author = 'dormic97', # Type in your name
Expand All @@ -18,6 +18,7 @@
long_description_content_type='text/markdown',
install_requires=[ # I get to this in a second
'requests',
'urllib'
],
classifiers=[
'Development Status :: 5 - Production/Stable', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
Expand Down

0 comments on commit 093da34

Please sign in to comment.