FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to do the String concatenation with PHP - running a little Parser based on cURL
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How to do the String concatenation with PHP - running a little Parser based on cURL [message #170777] Thu, 25 November 2010 18:09 Go to next message
matze is currently offline  matze
Messages: 5
Registered: November 2010
Karma: 0
Junior Member
Hello dear folks

i am currently workin on a little parser with cURL - and i have some
questions here: How to do the String concatenation with PHP ; note i
wanna do it with curl!

the target URL: http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=572.8745475728288
click all checkbuttons
Results: approx 6400 results
Here i can provide some "more help for getting the target!" - btw see
three detail page:

http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779 &SchulAdresseMapDO=116191
http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779 &SchulAdresseMapDO=116270
http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779 &SchulAdresseMapDO=188268

btw: we can loop over the results - with a iteration -

especially i wanna know: how to do the String concatenation with PHP ;
note i wanna do it with curl!


how to do the String concatenation with PHP ; note i wanna do it with
curl!




function get_page_data($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
if($output!=false && $_POST['dt']=='No')
return $output;
curl_close($ch);
}

for($i=1;$i<=$match[1];$i++)
{
$url = "http://www.example.com/page?page={$i}";
$data = get_page_data($url);
if($data) {
$cleaned = string_between('onload="check();">', '</body>', $data);
return = stip_tags($cleaned, '<table><tr><td><div>');
}
}

any and all help will be greatly appreciated

love to hear from you

best regards
Re: How to do the String concatenation with PHP - running a little Parser based on cURL [message #170778 is a reply to message #170777] Thu, 25 November 2010 18:27 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(matze)

> i am currently workin on a little parser with cURL - and i have some
> questions here: How to do the String concatenation with PHP ; note i
> wanna do it with curl! […]

You should bookmark the PHP manual.

http://www.php.net/manual/en/

See the section 'Operators' for your string problem.

Micha
Re: How to do the String concatenation with PHP - running a little Parser based on cURL [message #170789 is a reply to message #170778] Fri, 26 November 2010 09:54 Go to previous messageGo to next message
matze is currently offline  matze
Messages: 5
Registered: November 2010
Karma: 0
Junior Member
On Nov 25, 7:27 pm, Michael Fesser <neti...@gmx.de> wrote:
> .oO(matze)
>
>> i am currently workin on a little parser with cURL - and i have some
>> questions here: How to do the String concatenation with PHP ; note i
>> wanna do it with curl! […]
>
> You should bookmark the PHP manual.
>
> http://www.php.net/manual/en/
>
> See the section 'Operators' for your string problem.
>
> Micha


Thx i want to do this.
i come back and report all the findings
Re: How to do the String concatenation with PHP - running a little Parser based on cURL [message #170790 is a reply to message #170777] Fri, 26 November 2010 12:29 Go to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 25/11/2010 19:09, matze escribió/wrote:
> i am currently workin on a little parser with cURL - and i have some
> questions here: How to do the String concatenation with PHP ; note i
> wanna do it with curl!

I'm sorry but I find it very difficult to understand your question and
I'm sure I'm not the only one. You've mentioned three fairly unrelated
pieces of info and it's not clear how they relate each other:

1. String concatenation
2. Curl
3. Writing a parser

My educated guess is that you are scrapping a third-party site and you
want to write a custom HTML parser to extract information but I'm not
sure that makes sense. Parsing HTML is *very* hard. Even PHP gurus use
some of the built-in parsers rather than writing their own.

Let's analyse the information provided:

> the target URL: http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=572.8745475728288
> click all checkbuttons
> Results: approx 6400 results
> Here i can provide some "more help for getting the target!" - btw see
> three detail page:
>
> http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779 &SchulAdresseMapDO=116191
> http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779 &SchulAdresseMapDO=116270
> http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779 &SchulAdresseMapDO=188268
>
> btw: we can loop over the results - with a iteration -

What's this? Is it site you are building? Is it the third-party site
you're scrapping? Is it something entirely different?


> especially i wanna know: how to do the String concatenation with PHP ;
> note i wanna do it with curl!

Curl is an HTTP library; I don't think it provides string manipulation
functions. What you do you want to do exactly?

> how to do the String concatenation with PHP ; note i wanna do it with
> curl!

If PHP, as Michael Fesser pointed out, you use the string concatenation
operator:

http://es.php.net/manual/en/language.operators.string.php


> function get_page_data($url) {
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, $url);
> curl_setopt($ch, CURLOPT_HEADER, 0);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> $output = curl_exec($ch);
> if($output!=false&& $_POST['dt']=='No')
> return $output;
> curl_close($ch);
> }

This uncommented function appears to download a remote file and return
it as string. Is it failing or something?


> for($i=1;$i<=$match[1];$i++)

You are looping something. We don't know what.

> {
> $url = "http://www.example.com/page?page={$i}";
> $data = get_page_data($url);
> if($data) {
> $cleaned = string_between('onload="check();">','</body>', $data);
> return = stip_tags($cleaned, '<table><tr><td><div>');

This exists the loop as soon as a download succeeds. Is that what you
intended?

> }
> }
>
> any and all help will be greatly appreciated

Again, what are you doing and what's the question?



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: All preciseinfo.org collections are updated
Next Topic: Get IP Address Help
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 18:07:11 GMT 2024

Total time taken to generate the page: 0.13655 seconds