Skip to content

Commit

Permalink
rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Sh committed Apr 12, 2024
1 parent 6c3913d commit 77f05e2
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 473 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM php:8.2-cli
#COPY . /usr/src/myapp
WORKDIR /var/www/html

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
php composer-setup.php \
php -r "unlink('composer-setup.php');"

COPY composer.phar /usr/local/bin/composer

CMD [ "php", "./keep-running.php" ]
14 changes: 5 additions & 9 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# Proxyrequest - parsing website - bypass cloudflare or any custom made protection
# Proxyrequest - Rotating proxy, Bypass Cloudflare, Free proxy lists

If you are looking for a way to parse website which is protected by cloudflare or some other custom made solution you are in the right place.

Usually if you need to get a few dozens of pages from website you can go directry for webiste and scrape data easily. Troubles comes if website has some kind of protection and you need to get a lot of data on regular basis.
Usually if you need to get a few dozens of pages from website you can go directory for website and scrape data easily. Issues comes if website has some kind of protection you need to get a lot of data on regular basis.

We handle all blocking from protection on our behalf.
You get data like you were requesting them directly.

This solution is good if you need to get web pages, images and any other files not bigger than 30MB at most.
Not good if you need to download videos (not now, maybe in the future).
This solution works for parsing and collection of data. It doesn't work for DDOS, spam sending or abusing internet.


Any javascript on requested page is not executed. You get the page as is. So if website enabled under protection mode this solution won't work.
This situation needs emulating browser which is resource taking and going to be expensive. Good news is that such delay for 5 seconds is not good for
users so if they use it they shoot themselves in the foot. If you need passing such protection, please contact me too. Just keep in mind that it's not passed by current solution you see.
Javascript is optionally executed if you need it. Essentially it's slower than just getting page as is so consider finding a way to get data without Javascript execution.

## Usage via GET request

Expand Down Expand Up @@ -60,7 +56,7 @@ users so if they use it they shoot themselves in the foot. If you need passing s
* you were requesting it directly
*/
$content = $proxyBuilder->getContent();
That's all
```

Expand Down
54 changes: 31 additions & 23 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
{
"name": "gorlovka/proxy-request-builder",
"description": "building requests via proxy",
"type": "library",
"keywords": ["proxy", "bypass"],
"authors": [
{
"name": "hohohoho",
"email": "[email protected]"
}
],
"license": "MIT",
"scripts": {
},
"autoload": {
"psr-4": {
"Gorlovka\\": "src/"
}
},
"config": {
"platform": {
"php": "5.4"
}
"name": "gorlovka/proxy-request-builder",
"description": "building requests via proxy",
"type": "library",
"keywords": [
"cloudflare bypass",
"clouflare",
"proxy",
"free-proxy",
"scan-proxy",
"public-proxy",
"socks-proxy",
"http-proxy",
"proxy-list"
],
"authors": [
{
"name": "Alex Sh",
"email": "[email protected]"
}

],
"scripts": {
},
"autoload": {
"psr-4": {
"Proxyrequest\\": "src/"
}
},
"config": {
"platform": {
"php": ">=5.4"
}
}
}
12 changes: 9 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ version: '3.8'

services:
proxyrequest:
stdin_open: true # docker run -i
tty: true # docker run -t
build: .
container_name: proxyrequest

ports:
- "8080:82"
- "8080:80"
volumes:
- ./src:/var/www/html
- .:/var/www/html

restart: unless-stopped
restart: "no"
extra_hosts:
- "host.docker.internal:host-gateway"
4 changes: 2 additions & 2 deletions exampleRotateProxy.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php


use Proxyrequest\ProxyRequestRotate;

$proxyRequestRotate = new ProxyRequestRotate();

$proxyRequestRotate = new \Proxyrequest\ProxyRequestRotate();

echo $proxyRequestRotate->getContent();
5 changes: 5 additions & 0 deletions src/ProxyRequestBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
class ProxyRequestBuilder
{

const FORMAT_JSON ='json',
FORMAT_TXT='txt';

private $format;

private $urlToGet;
private $token;
private $messageErrorLast;
Expand Down
200 changes: 1 addition & 199 deletions src/ProxyRequestCloudflare.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,207 +4,9 @@
* Created on: Jun 23, 2020 12:31:08 AM
*/

namespace Gorlovka;
namespace Proxyrequest;

class ProxyRequestCloudflare
{

const FORMAT_JSON ='json',
FORMAT_TXT='txt';

private $format;

private $urlToGet;
private $token;
private $messageErrorLast;
private $server;

/**
*
* @var bool
*/
private $isMobileOnlyUserAgent;

/**
*
* @var string
*/
private $cookies;

/**
*
* @var string
*/
private $referer;
private $statusCode = null;

/**
*
* Returned in response from server
*
* @var string
*/
private $userAgentUsed;
private $cookiesUsed;
private $refererUsed;

private $responseCookies;
private $responseHeaders;

/**
*
* @param string $server
* @param string $urlToGet
* @param string $token
* @param string $isMobileOnlyUserAgent any value is treated as yes, empty for no
* @param [] $cookies
* @param string $referer
*/
public function __construct($server, $urlToGet, $token,
$isMobileOnlyUserAgent = '', $cookies = [],
$referer = '')
{

$this->server = $server;
$this->urlToGet = $urlToGet;
$this->token = $token;
$this->isMobileOnlyUserAgent = $isMobileOnlyUserAgent;
$this->cookies = $cookies;
$this->referer = $referer;
}

public function getStatusCode()
{
return $this->statusCode;
}

public function getMessageErrorLast()
{
return $this->messageErrorLast;
}

public function getUserAgentUsed()
{
return $this->userAgentUsed;
}

public function getCookiesUsed()
{
return $this->cookiesUsed;
}

public function getRefererUsed()
{
return $this->refererUsed;
}

/**
* @return array
*/
public function getResponseCookies()
{
return $this->responseCookies;
}

/**
* @return array
*/
public function getResponseHeaders()
{
return $this->responseHeaders;
}



public function getUrlFinal()
{
$urlEncoded = base64_encode($this->urlToGet);

$domain = $this->server;

$token = $this->token;

$params = http_build_query([
'token' => $token,
'urlToGet' => $urlEncoded,
'isMobileOnlyUserAgent' => $this->isMobileOnlyUserAgent,
'cookies' => $this->cookies,
'referer' => $this->referer
]);

$urlFinal = "$domain/api/forwardRequestInParallelV2?$params";




return $urlFinal;
}

/**
* Returns false if request failed,
* check $messageErrorLast field for more information
*
*
* @staticvar int $timesTried
* @return boolean|string
*/
public function getContent()
{
static $timesTried = 0;

$urlFinal = $this->getUrlFinal();


try
{
$dataInJson = file_get_contents($urlFinal);
}
catch (\Exception $e)
{

if ($timesTried < 2) {
$timesTried++;
return $this->getContent();
}

$timesTried = 0;

return false;
}


$response = json_decode($dataInJson, true);


$this->messageErrorLast = $response['message'];

$value = $response['value'];

/**
* что-то не так на нашей стороне
*/
if (!array_key_exists('statusCode', $value)) {
return false;
}


if (!$response['success']) {
return $this->getContent();
}

$statusCode = $value['statusCode'];


$this->userAgentUsed = $value['userAgentUsed'];
$this->statusCode = $statusCode;
$this->refererUsed = $value['refererUsed'];
$this->cookiesUsed = $value['cookiesUsed'];

$this->responseHeaders = $value['headers'];

$contentInBase64 = $value['content'];

return base64_decode($contentInBase64);
}

}
Loading

0 comments on commit 77f05e2

Please sign in to comment.