哪个使用? file_get_contents,file_get_html或cURL? [英] Which to use? file_get_contents, file_get_html, or cURL?

查看:307
本文介绍了哪个使用? file_get_contents,file_get_html或cURL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从网页上的表格中刮除数据。然后我想将这些数据存储在数组中,以便我以后将其存储在数据库中。我非常不熟悉这个功能,所以我想使用最简单的方法。

I need to scrape data from a table on a web page. I'd then like to store this data in an array, so that I can later store it in a database. I'm very unfamiliar with this functionality, so I'd like to use the most simple method possible.

我应该使用哪个? file_get_contents file_get_html cURL

Which should I use? file_get_contents, file_get_html, cURL?

推荐答案


  1. 您可以使用 curl()或<$ c

  2. 然后,使用正则表达式提取您需要的内容( file_get_contents() > preg_match())

  3. 最后,将内容插入数据库。

  1. You can use curl() or file_get_contents() to get the contents of the page.
  2. then, using the regular expressions to extract the content you need (preg_match())
  3. finally ,insert the content to database.


$ b b

您可以使用crontab命令(Linux:crontab -e)使php脚本自动执行。

You can using the crontab command (Linux: crontab -e) to make the php script execute automatically.

我的英语很差,所以我希望有人给我意见。谢谢!

My English is poor, so I hope anyone give me opinion. Thanks!

这篇关于哪个使用? file_get_contents,file_get_html或cURL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆