This article mainly introduces how php can match divs with class in html and select the content. The method involves the use of curl and regular matching skills, which has certain reference value. Friends in need can refer to it
The example in this article describes the method of php regularly matching divs with classes in html and selecting the content. Share it with everyone for your reference. The specific analysis is as follows:
Look at a piece of html code first:
The code is as follows:
Tide Time (Hrs) | 00:58 | 05:20 | 13:28 | 21:15 |
Tide height (cm) | 161 | 75 | 288 | 127 |
This is part of the source program. In order to make it easier to understand, a large part has been deleted. Only the content in the
First use file_get_content or curl to get the content part on the home page. I use curl.
The code is as follows:
That’s it, no explanation required. If you know PHP, read the code and print it to see the effect.
I hope this article will be helpful to everyone’s PHP programming design.