Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Get the html content from a website using php

Get the html content from a website using php

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
helpphphtmldatabasemysql
5 Posts 3 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joshin Joy
    wrote on last edited by
    #1

    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.

    J 1 Reply Last reply
    0
    • J Joshin Joy

      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.

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      You can use PHP: file_get_contents - Manual[^] when enabling the fopen wrappers[^]. For HTTPS, php_openssl must be installed and enabled.

      J 1 Reply Last reply
      0
      • J Jochen Arndt

        You can use PHP: file_get_contents - Manual[^] when enabling the fopen wrappers[^]. For HTTPS, php_openssl must be installed and enabled.

        J Offline
        J Offline
        Joshin Joy
        wrote on last edited by
        #3

        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!

        J U 2 Replies Last reply
        0
        • J Joshin Joy

          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!

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • J Joshin Joy

            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!

            U Offline
            U Offline
            User 13843883
            wrote on last edited by
            #5

            https://somewebsite.com/ this site is null

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups