PHP cURL语言请求和解析

时间:2022-10-19 18:18:40

I am having some problems sending a cURL request with a language (en_US) for example.

我在使用语言(en_US)发送cURL请求时遇到一些问题。

1) Could anyone show me an example of how to send a cURL request with US language, and then get the HTML source code.

1)任何人都可以向我展示如何使用美国语言发送cURL请求的示例,然后获取HTML源代码。

2) Next, what I am trying to do is to parse some information from the HTML Source code it gave me. What I want to parse looks like this:

2)接下来,我要做的是解析它给我的HTML源代码中的一些信息。我要解析的内容如下所示:

http://pastebin.com/05qwEvyj

There are multiple '', so it just has to get 'for each' since it can be a number between 0-5. Next, i want to get the parts where it says 'some text here..' and the 'some url here'.

有多个'',因此它必须得到'每个',因为它可以是0-5之间的数字。接下来,我想得到的部分是“这里有些文字......”和“有些网址”。

I hope you can understand me, but to begin with I would just want to send a request with a language. Then we can take number 2 afterwards!

我希望你能理解我,但首先我只想用语言发送请求。之后我们可以拿2号!

1 个解决方案

#1


0  

So, you would like to curl-request a set of pages within a given range? Here is a basic post on using curl in php to 'get' a page:

那么,您想要在给定范围内卷曲请求一组页面吗?这是一篇关于在php中使用curl来“获取”页面的基本帖子:

PHP cURL GET request and request's body

PHP cURL GET请求和请求的正文

Establish your limits and iterate through the set. Check this posting: Fetching all the images from url

确定您的限制并迭代整个集合。查看此帖子:从网址获取所有图片

It looks as if, from your pastebin, you are either

从你的pastebin看起来好像你也是

1) only grabbing part of the page due to mistargeting (as in you thought you were requesting the entire page but only requested a portion) error

1)由于错误定位而只抓取部分页面(如您认为您要求整个页面但只请求了一部分)错误

2) grabbing all of what you actually requested which is only a part of page such as a div.

2)抓住你实际要求的所有内容,这只是页面的一部分,比如div。

Get some basic request code working (shouldn't take more than a couple of minutes) and if it still doesn't work post the code itself.

获取一些基本的请求代码(不应该花费超过几分钟),如果它仍然无法发布代码本身。

Cheers

#1


0  

So, you would like to curl-request a set of pages within a given range? Here is a basic post on using curl in php to 'get' a page:

那么,您想要在给定范围内卷曲请求一组页面吗?这是一篇关于在php中使用curl来“获取”页面的基本帖子:

PHP cURL GET request and request's body

PHP cURL GET请求和请求的正文

Establish your limits and iterate through the set. Check this posting: Fetching all the images from url

确定您的限制并迭代整个集合。查看此帖子:从网址获取所有图片

It looks as if, from your pastebin, you are either

从你的pastebin看起来好像你也是

1) only grabbing part of the page due to mistargeting (as in you thought you were requesting the entire page but only requested a portion) error

1)由于错误定位而只抓取部分页面(如您认为您要求整个页面但只请求了一部分)错误

2) grabbing all of what you actually requested which is only a part of page such as a div.

2)抓住你实际要求的所有内容,这只是页面的一部分,比如div。

Get some basic request code working (shouldn't take more than a couple of minutes) and if it still doesn't work post the code itself.

获取一些基本的请求代码(不应该花费超过几分钟),如果它仍然无法发布代码本身。

Cheers