Get the html content from a website using php
-
Hai,
.centerDiv { width: 1000px; height:600px; margin: 0 auto; } .div1 { width: 500px; height:600px; float:left; } .div2 { width: 500px; height:600px; float:left; }
this is a html code I created. when this page is loaded. the two links in the 'div' will also be loaded. In the original link page there will be a username and password to enter. the user will manually enter this username and password and submit it. then a new page will be loaded which will display the current temperature of two sites. what I need is get that temperature value and load it to a MySQL database. this is my problem. what I plan is to get the html of the loaded link. and search for the element temperature and get the temperature value. but I don't know how to grasp the HTML code of the link. Can Any one help me to grasp the html of link site using php or any other methods!! Please help.
-
Hai,
.centerDiv { width: 1000px; height:600px; margin: 0 auto; } .div1 { width: 500px; height:600px; float:left; } .div2 { width: 500px; height:600px; float:left; }
this is a html code I created. when this page is loaded. the two links in the 'div' will also be loaded. In the original link page there will be a username and password to enter. the user will manually enter this username and password and submit it. then a new page will be loaded which will display the current temperature of two sites. what I need is get that temperature value and load it to a MySQL database. this is my problem. what I plan is to get the html of the loaded link. and search for the element temperature and get the temperature value. but I don't know how to grasp the HTML code of the link. Can Any one help me to grasp the html of link site using php or any other methods!! Please help.
You can use PHP: file_get_contents - Manual[^] when enabling the fopen wrappers[^]. For HTTPS,
php_openssl
must be installed and enabled. -
You can use PHP: file_get_contents - Manual[^] when enabling the fopen wrappers[^]. For HTTPS,
php_openssl
must be installed and enabled.Thank you for your reply. but how can i get the url from div? after entering the username and password. url in the div will be changed because a new page will be loaded. Please help!
-
Thank you for your reply. but how can i get the url from div? after entering the username and password. url in the div will be changed because a new page will be loaded. Please help!
You wrote
Quote:
this is a html code I created
so I thought that you know the URLs and just want to load them to get the temperatures. If you want to load a page from a login form, you have to pass the URL with parameters as send by the form when submitting. If this works depends on the form (how the the login parameters are passed). If it is not your site, it is probably intended by the site owner that you can't automate the process. Then you can only ask him if he provides an API to do such.
-
Thank you for your reply. but how can i get the url from div? after entering the username and password. url in the div will be changed because a new page will be loaded. Please help!
https://somewebsite.com/ this site is null