我想知道如何使用 php 从网站上抓取源代码的内容。我尝试使用http://simplehtmldom.sourceforge.net/并查看了如何在 PHP 中解析和处理 HTML/XML?我仍然很难从源代码中获取信息。如您所见,源代码的主页包含作者链接列表,其中包括年份和着书数量。
<div id="fleft">
<ul>
<li><a href="http://www.books.com/john-smith/index.html">John Smith (2011-2012)</a> : 11 books
<li><a href="http://www.books.com/bobby-bob/index.html">Bobby Bob (2011-2012)</a> : 89 books
....
</ul>
</div>
我点击 john smith,它会打开 john smith 写的书籍列表。
<h1>John Smith (11 Books)</h1>
<div id="fleft">
<ul>
<li><a href="http://www.books.com/john-smith/best-book.html">Best Book</a>
<li><a href="http://www.books.com/john-smith/other-best-book.html">Other Best Book</a>
....
</ul>
</div>
我点击其中一本书“最好的书”,它会显示书名和作者以及这本书的整个故事。
<div id="bookbox">
<h1>Book : Best Book</h1>
<h2>Aurther : John Smith</h2>
<pre>
story of the best book......
.......
....
the end
</pre>
我希望能够获取所有作者姓名和他们的年份、书籍列表以及书籍的内容。实际上作为数据集。有人可以帮助我或向我展示 php 的代码示例来实现这一点。我想创建一个包含所有作者姓名、他们的生活年份、他们创建的书籍、书名、类别、书籍内容等信息的数据库