📜 ⬆️ ⬇️

We automate the work with the site in 5 minutes on the example of Yandex. Mails using NetExport

Sometimes, sometimes you need to automate some processes on another site. Log in to the site, download a file, open a page. Often you have to figure out the site code to find how to write a curl request correctly.

I bring to your attention the way I use myself to make my life much easier and automate everything and everyone, from checking emails to loading data into a telebank. I will try, using the example of Yandex.mail, to show how to generate a curl php script very quickly and almost without programming for entering any site and downloading content in automatic mode.

First, we need to install the Firebug extension for the Firefox browser. After that, install the extension for FireBug NetExport

Latest versions of netExport allow you to automatically collect network logs of your actions in the HTTP Archive format.
')
Now we are moving to the site that interests us, in this case it will be mail.yandex.ru . After that, it is better to clear all the cookies and browser cache. Now turn on FireBug by clicking on the bug icon on the browser status bar. After that we turn on the Network, turn off the cache just in case.

image

If the NetExport plugin is installed, you will see the “Export” button in the Firebug panel and a yellow circle next to it. In order for the plugin to record all your actions in automatic mode, you must set the default directory to record the logs and click on the yellow circle (it will turn green, as in the picture).

image

Now just go under your account and do the action you need. In my case, I just need to make a login and go to the page with the letters. Done, stop NetExport by clicking on the green circle. In the folder that we chose by default, several files appeared. They can be analyzed using the online viewer and write code for automation.

However, I wrote a small service that allows you to do this automatically. Following the link har2php.sharecoder.com you can simply upload your log file to the service and it will write the PHP code for you. In my case, I need to upload the file “passport-ckicheck.yandex.ru + 2010-02-18 + 10-15-21.har” there and voila :) I did it for myself, so I don’t digest large log files very well, but he knows his work well. The service does not store the sent data and keeps it only in the current session. However, for greater security, it is recommended to preliminarily, before sending the HAR file to the service, to replace the real logins and passwords with any characters.

Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  1. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  2. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  3. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  4. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  5. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  6. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  7. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  8. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  9. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  10. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  11. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  12. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  13. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  14. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  15. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  16. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  17. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  18. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  19. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  20. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  21. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  22. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  23. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  24. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );
  25. Copy Source | Copy HTML $cookie_file = 'cookie.txt' ; $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL, 'https://passport.yandex.ru/passport?mode=auth' ); curl_setopt( $ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6' ); curl_setopt( $ch , CURLOPT_REFERER, 'http://mail.yandex.ru/' ); curl_setopt( $ch , CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $ch , CURLOPT_COOKIEJAR, $cookie_file ); curl_setopt( $ch , CURLOPT_COOKIEFILE, $cookie_file ); $header = array (); $header [] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' ; $header [] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ; $header [] = 'Accept-Language: ru,en-us;q=0.7,en;q=0.3' ; $header [] = 'Pragma: ' ; curl_setopt( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch , CURLOPT_POST, true ); $fields = array (); $fields [] = 'login=xxxxx' ; $fields [] = 'passwd=xxxxx' ; $fields [] = 'retpath=xxxxx' ; $fields [] = 'twoweeks=yes' ; curl_setopt( $ch , CURLOPT_POSTFIELDS, implode( '&' , $fields )); curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch , CURLOPT_AUTOREFERER, true ); curl_exec( $ch ); curl_close( $ch );

The code, after several cosmetic changes, can be used as intended :)

PS for those who are still afraid to send logs to the site, open the source code of the current version of the service:

Copy Source | Copy HTML
  1. <? php
  2. $ data = implode ( '' , file ( $ uploadfile ));
  3. $ data = json_decode ( $ data );
  4. unlink ( $ uploadfile );
  5. $ lines = parseData ( $ data );
  6. function parseData ( $ data )
  7. {
  8. $ lines = array ();
  9. foreach ( $ data -> { 'log' } -> { 'pages' } as $ page ) {
  10. $ exclude_url = array ();
  11. foreach ( $ data -> { 'log' } -> { 'entries' } as $ entrie ) {
  12. if ( $ entrie -> { 'pageref' }! = $ page -> { 'id' }) continue ;
  13. if (! empty ( $ exclude_url [ $ entrie -> { 'request' } -> { 'url' }])) continue ;
  14. if ( false and preg_match ( '/\d+-\d+-\d+T\d+:\d+:\d+\.(\d+)/' , $ entrie -> { 'startedDateTime' }, $ m )) {
  15. $ id = strftime ( '% Y% m% d% H% M% S' , strtotime ( $ entrie -> { 'startedDateTime' })). $ m [ 1 ];
  16. } else {
  17. $ id = $ entrie -> { 'startedDateTime' };
  18. }
  19. $ lines [ $ id ] [] = '$ cookie_file = \' cookie.txt \ ';' ;
  20. $ lines [ $ id ] [] = '' ;
  21. $ headers = array ();
  22. foreach ( $ entrie -> { 'request' } -> { 'headers' } as $ header ) {
  23. $ headers [ $ header -> { 'name' }] = $ header -> { 'value' };
  24. }
  25. $ lines [ $ id ] [] = '$ ch = curl_init ();' ;
  26. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_URL, \' ' . $ entrie -> { ' request ' } -> { ' url ' }. ' \ ');' ;
  27. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_USERAGENT, \' ' . $ headers [ ' User-Agent ' ]. ' \ ');' ;
  28. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_REFERER, \' ' . $ headers [ ' Referer ' ]. ' \ ');' ;
  29. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_ENCODING, \' ' . $ headers [ ' Accept-Encoding ' ]. ' \ ');' ;
  30. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookie_file);' ;
  31. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ cookie_file);' ;
  32. $ lines [ $ id ] [] = '' ;
  33. $ lines [ $ id ] [] = '$ header = array ();' ;
  34. $ lines [ $ id ] [] = '$ header [] = \' Accept: ' . $ headers [ 'Accept' ]. '\'; ' ;
  35. $ lines [ $ id ] [] = '$ header [] = \' Accept-Charset: ' . $ headers [ 'Accept-Charset' ]. '\'; ' ;
  36. $ lines [ $ id ] [] = '$ header [] = \' Accept-Language: ' . $ headers [ 'Accept-Language' ]. '\'; ' ;
  37. $ lines [ $ id ] [] = '$ header [] = \' Pragma: \ ';' ;
  38. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header);' ;
  39. switch ( $ entrie -> { 'request' } -> { 'method' }) {
  40. case 'GET' :
  41. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_POST, false);' ;
  42. break ;
  43. case 'POST' :
  44. if ( $ entrie -> { 'request' } -> { 'postData' } -> { 'mimeType' } == 'application / x-www-form-urlencoded' ) {
  45. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_POST, true);' ;
  46. } else {
  47. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_POST, false);' ;
  48. }
  49. $ lines [ $ id ] [] = '' ;
  50. $ lines [ $ id ] [] = '$ fields = array ();' ;
  51. foreach ( $ entrie -> { 'request' } -> { 'postData' } -> { 'params' } as $ param ) {
  52. $ lines [ $ id ] [] = '$ fields [] = \' ' . $ param -> { 'name' }. '=' . $ param -> { 'value' }. '\'; ' ;
  53. }
  54. $ lines [ $ id ] [] = '' ;
  55. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_POSTFIELDS, implode (\' & \ ', $ fields));' ;
  56. break ;
  57. default :
  58. die (print_r ( $ entrie ));
  59. }
  60. if ( $ entrie -> { 'response' } -> { 'status' } == '302' ) {
  61. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true);' ;
  62. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_AUTOREFERER, true);' ;
  63. $ exclude_url [ $ entrie -> { 'response' } -> { 'redirectURL' }] = true ;
  64. } else {
  65. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, false);' ;
  66. $ lines [ $ id ] [] = 'curl_setopt ($ ch, CURLOPT_AUTOREFERER, false);' ;
  67. }
  68. $ lines [ $ id ] [] = 'curl_exec ($ ch);' ;
  69. $ lines [ $ id ] [] = 'curl_close ($ ch);' ;
  70. $ lines [ $ id ] [] = '' ;
  71. }
  72. }
  73. return $ lines ;
  74. }
  75. ?>

Source: https://habr.com/ru/post/84683/


All Articles