How to log in to the website via a script?

Good day,everyone

Let's have a news website with the possibility of registration of users
If the user is registered, he displays one of the content; if not, then the other

How do I tell the script which I'm developing (currently in Python and PHP) that the username and password from this news site, give me the html data for a registered user?

I understand that when you sign in on the website have the cookies and session to check. Let's say I can replace the headers by copying them from Chrome Debugger, but because these headers will change? And it will do it work?

Example of giving for one site Request Headers below when entering via GET to the page. It turns out if the cookies run out, then every time I need to go to the site manually, copy the new value and paste it into the script?

Accept-Encoding:gzip, deflate
Cookie:PHPSESSID=sgjjv462jhc8o7jbqna6u7u1vs7; example-mo_ename=cad7d6de252ee31018d968134dcd2518f78ff; example-mo_type_auth=employer
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Request Cookies:
PHPSESSID sgjjv46jhc8do7jbqn6u7u1vs7 N/A N/A N/A 38 
example-mo_ename cad7d6de25ee31034718df96813dcd2518f78ff N/A N/A N/A 53 
example-employer mo_type_auth

Response -- the html page
June 14th 19 at 19:59
3 answers
June 14th 19 at 20:01
Parameters: CURLOPT_COOKIE and CURLOPT_COOKIEFILE is what you are interested in
Thanks, and how about the fact that cookies might dry up? - jeramy commented on June 14th 19 at 20:04
, But no way. Runs out - perhalogenated. - Giles_Luettgen18 commented on June 14th 19 at 20:07
June 14th 19 at 20:03
Cookies are the least of the problems. Any imputed library for working with http is able to keep them during the session, save at the end and upload later. The fun begins with all sorts of xsrf and other protections. Try, materials on the Internet a ton. For example in python+requests -
June 14th 19 at 20:05
Open the debugger and make the authorization. View the query that sends the data to the site. Surely it sends the username, password + something. Sometimes sites can send dynamic parameters in order to protect from automatic authorization, but it is unlikely your case. Also go may not a password and its hash. Analyze a query and clone - it, you will need to simulate every time you will need to log in. From libraries, suitable even for the default requests from Python. And do not need any selenium, you're not shelling passerine nests are going to arrange.

Find more questions by tags Web DevelopmentParsing