In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "php using curl to simulate the method of collecting pages after logging in". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
The homework I received today is to get inventory from a website, but this website needs to be logged in. I used fsockopen to pass the entire header header, which is useless. I can only resort to curl.
Let's talk about how to open the curl module:
(1)Copy: libeay32.dll, ssleay32.dll from php directory to windows directory.
(2)Open php.ini, look for "extension_dir = xxxxx", and make sure there is php_curl.dll in the following file directory.
(3)Also php.ini, look for "extension=php_curl.dll" and make sure it is not commented (no ';' in front).
(4)Restart apache, if the curl_init(); statement appears error prompt, then the installation is not successful.
The copy code is as follows:
$curl = curl_init();
$cookie_jar = tempnam('./ tmp','cookie');
curl_setopt($curl, CURLOPT_URL,'http://b2b.bookuu.com/b2b_club/checkUser.jsp');//Write the login interface here
curl_setopt($curl, CURLOPT_POST, 1);
$request = 'user=xxx&password=xxx';
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);//pass data
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_jar);//Save returned cookie information in $cookie_jar file
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//Sets whether the returned data is automatically displayed
curl_setopt($curl, CURLOPT_HEADER, false);//Sets whether header information is displayed
curl_setopt($curl, CURLOPT_NOBODY, false);//Set whether to output page content
curl_exec($curl);
curl_close($curl);
$curl2 = curl_init();
curl_setopt($curl2, CURLOPT_URL, 'http://b2b.bookuu.com/search/b2b_zxsm_new.jsp');//Which page do you want to get information from after login
curl_setopt($curl2, CURLOPT_HEADER, false);
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl2, CURLOPT_COOKIEFILE, $cookie_jar);
$content = curl_exec($curl2);
"php use curl simulation login after the collection of page method tutorial" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.