如何最好地在 PHP 中搜索网站并检索数据?

发布于 2024-07-27 22:37:26 字数 236 浏览 1 评论 0原文

尝试学习更多 PHP。 这就是我所追求的。

本质上,我想搜索一个网站并将数据返回到我自己的网站。

  1. 在表单中添加一些关键字。
  2. 使用这些关键字查询 Monster.com 等网站,以获取与输入的关键字匹配的结果。
  3. 获取该数据并将其返回到我自己的网站。

这样的事情有多难? 我承认上述概述过于简单,但非常感谢您提供的任何提示。

Trying to learning some more PHP. Here is what I'm after.

Essentially, I would like to search a website and return data to my own website.

  1. Add a few keywords to a form.
  2. Use those keywords to query a website such as monster.com for results that match the keywords entered.
  3. Grab that data and return it to my own website.

How hard is something like this? I acknowledge the above outline is oversimplified but any tips you can offer are much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苏大泽ㄣ 2024-08-03 22:37:26

如果您正在查询一个具有指定用于此类功能的 API 的网站,那么您就很容易了。 只需调用 API 的相应搜索功能即可完成。

如果您正在查询的网站没有 API,您仍然可以使用正确的参数通过 HTTP GET 来搜索该网站。 然后,您只需使用脚本和一些正则表达式函数来浏览文件以获取搜索结果。

这里有一个关于使用 PHP 进行屏幕抓取的小教程。 希望这会对您有所帮助。 这样做的问题是,一般来说,如果网站没有让访问他们的数据变得容易,他们可能不希望你这样做。

If you're querying a site that has an API designated for this kind of functionality, you're on easy street. Just call the API's appropriate search function and you're all set.

If the site you're querying doesn't have an API, you still might be able to search the site with an HTTP GET using the right parameters. Then you just need to scrape through the file for the search results with your script and a few regex functions.

Here's a little tutorial on screen scraping with PHP. Hopefully that will be of some help to you. The trouble with this is that in general if the site hasn't made it easy to access their data, they might not want you to do this.

浮世清欢 2024-08-03 22:37:26

输入雅虎查询语言 (yql)。 该服务可让您使用 xpath 等工具从网站获取数据并将其转换为易于使用的 xml 或 json 格式。 该语言的结构与 sql 类似(因此得名)。

我已经将它用于其他网站,为没有它的网站构建 rss 提要,而且它非常容易学习。

http://developer.yahoo.com/yql/

Enter Yahoo Query Language (yql). It's a service that let's you use things like xpath to get data from websites and put them into an easy to use xml or json format. The language is similarly structured to sql (hence the name).

I've used it for other sites to build rss feeds for sites that didn't have it and it was pretty easy to learn.

http://developer.yahoo.com/yql/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文