[Help] Parsers

Everything PHP-related! Discuss scripts, host challenges, request a script, or just ask for plain old help.

Moderators: IRC Operators, Support Team

lovely3000
User
User
Posts: 78
Joined: Fri Oct 06, 2006 5:43 am

[Help] Parsers

Postby lovely3000 » Mon Dec 29, 2008 10:27 pm

[code]<?php
$a=array(
"lets hack them."=>"1",
"I have his pass."=>"2",
"I have his IP, lets do it."=>"3",
"let's do it. Can't wait to get loaded."=>"4",
"I'm ready but Do you think he'll find out?"=>"5",
"I'm gonna get started on his recovery questions"=>"6",
"Do his questions and I'll do his account details"=>"7");
print_r(array_rand($a,1));
?>[/code]
Yay me first parser!

Hey does any1 know how to parser other sites?

Like say if $this is before $this2 read is before but delete $unneeded.

like this site http://4q.cc/index.php?pid=fact&person=chuck

[code]<div id="factbox">
random chuck fact here</div>[/code]

I dont want to use line count to grab it because people always alter their pages and they're less likely to edit the specific codes. They mostly enhance the page look which scrolls lines.

=P lol

[code]<?php
$file = file_get_contents("http://4q.cc/index.php?pid=fact&person=chuck");
echo $file;
?>[/code]

I got that far before i realised i couldn't find what i needed.

It would be great for some help there. thanx!!

---------------

I got what i needed ty joshR!
Last edited by lovely3000 on Wed Dec 31, 2008 4:18 am, edited 2 times in total.
I would rather see a sermon than hear one any day. I'd rather have you walk with me, than merely point the way. The eye is a more ready pupil than ever was the ear, good advice is often confusing, but example is always clear.

- www.phpro.org
User avatar
Tea
User
User
Posts: 1019
Joined: Fri Jul 25, 2008 3:42 pm
Location: #Coffey522
Contact:

Postby Tea » Mon Dec 29, 2008 10:54 pm

1st 1 isn't a parser you're just echoing a random line from the array.

chuck norris parser:

<?php
$file = file_get_contents("http://4q.cc/index.php?pid=fact&person=chuck");
preg_match("/Chuck Norris(.*)<\/div>/",$file,$lol);
die("\nChuck Norris".$lol[1]."\n");
?>
Image
^ made by the very lovely xrox <3
lovely3000
User
User
Posts: 78
Joined: Fri Oct 06, 2006 5:43 am

Postby lovely3000 » Mon Dec 29, 2008 11:14 pm

shhhh, else ppl will know i'm noob at this.

The php you're giving me is regex, i dont know regex therefore i can't edit it for other sites and it's not doing what i want it do it.

It read if the line contains chuck which isn't what i want.

code]<div id="factbox">
random chuck fact here</div>[/code]

I want if <div id="factbox"> is before "random chuck fact" and </div> is after chuck fact, read random chuck fact and an option to remove what i dont want.
I would rather see a sermon than hear one any day. I'd rather have you walk with me, than merely point the way. The eye is a more ready pupil than ever was the ear, good advice is often confusing, but example is always clear.

- www.phpro.org
lovely3000
User
User
Posts: 78
Joined: Fri Oct 06, 2006 5:43 am

Postby lovely3000 » Tue Dec 30, 2008 6:11 am

ok ok, parser isn't just using php? it's geting the info from the site and using it?

anyway help me with that >.<

Tutorials blow. So much things they're telling me that i dont need to know.


I got what i needed ty joshR!
I would rather see a sermon than hear one any day. I'd rather have you walk with me, than merely point the way. The eye is a more ready pupil than ever was the ear, good advice is often confusing, but example is always clear.

- www.phpro.org
Billyb0b
User
User
Posts: 757
Joined: Fri Apr 14, 2006 7:58 am

Postby Billyb0b » Wed Dec 31, 2008 12:00 pm

preg_match("/<div id=\"factbox\">(.*)<\/div>/",$file,$lol);

It'll be $lol[1]
Ward
User
User
Posts: 615
Joined: Sat Jul 21, 2007 10:57 pm
Location: Brussels, Belgium
Contact:

Postby Ward » Wed Dec 31, 2008 12:16 pm

Stop forcing regex on someone...


Have a look at the functions mentioned here:
http://php.net/manual/en/ref.strings.php
and more specifically, ones like "strpos" and "substr" might interest you :wink:


And a parser in this context is something that takes in (a lot of) data and gets out the essential/needed parts
LustraTheGoodMan
User
User
Posts: 334
Joined: Mon Nov 24, 2008 1:28 pm
Location: #lustra

Postby LustraTheGoodMan » Wed Dec 31, 2008 6:42 pm

[quote="Ward"]Stop forcing regex on someone...


Have a look at the functions mentioned here:
http://php.net/manual/en/ref.strings.php
and more specifically, ones like "strpos" and "substr" might interest you :wink:


And a parser in this context is something that takes in (a lot of) data and gets out the essential/needed parts[/quote]
Agreed.
lovely3000
User
User
Posts: 78
Joined: Fri Oct 06, 2006 5:43 am

Postby lovely3000 » Wed Dec 31, 2008 7:11 pm

[quote="Ward"]

And a parser in this context is something that takes in (a lot of) data and gets out the essential/needed parts[/quote]

Oh ty, I guess i should have looked up what parser meant before i got into making one. :P

I just wanted to make my mirc socketing easier. Socketing a website directly is so hard in mirc. When i saw the parsers on ultimate parser list and how simple they came out. I just had to know how. ^_^

I knew before hand too that website scripting language is more flexiable and simpler than mirc script language.

Thanx every1.

And ya i dont need to know regex. I'm not making complicated and long parsers. I'm making 4 lines max. Most will be one liners so what josh taught me is all i really wanted to know.
I would rather see a sermon than hear one any day. I'd rather have you walk with me, than merely point the way. The eye is a more ready pupil than ever was the ear, good advice is often confusing, but example is always clear.

- www.phpro.org
Bluebus112
Server Administrator
Server Administrator
Posts: 417
Joined: Sat Sep 15, 2007 3:24 pm

Postby Bluebus112 » Wed Dec 31, 2008 10:03 pm

mSL is really easy compared to PHP. And it isn't just "website scripting languge", it's PHP and there are other languages that can be used instead of PHP.
lovely3000
User
User
Posts: 78
Joined: Fri Oct 06, 2006 5:43 am

Postby lovely3000 » Thu Jan 01, 2009 5:01 am

[quote="Bluebus112"]mSL is really easy compared to PHP. And it isn't just "website scripting languge", it's PHP and there are other languages that can be used instead of PHP.[/quote]

>.> that's why i said website scripting.

I've done html in school and on my own. There is css in ipb forums. Java on rs. what else... idk...

They're easy compared to msl. You seen direct socket scripts on msl?? Drives me up the wall. Php was so simple. Just 6 lines of pure understanding. To do what i did with php and understand what i'm doing, i'd have to do 20 lines in mirc.

Yes i know regex makes it's shorter but note the word "understand". I dont care to. I made 3 regex scripts took me like half an hour each just making scripts shorter and I look at it now, i dont even know what I did... I can honestly say it would take me another half an hour or more just to edit my own regex scripts.

I highly prefer socketing a parser than socketing directly.
I would rather see a sermon than hear one any day. I'd rather have you walk with me, than merely point the way. The eye is a more ready pupil than ever was the ear, good advice is often confusing, but example is always clear.

- www.phpro.org
lovely3000
User
User
Posts: 78
Joined: Fri Oct 06, 2006 5:43 am

Postby lovely3000 » Thu Jan 01, 2009 5:07 am

to Billyb0b

People have their own way of doing what they need to get done. Forcing your way onto others shouldn't be something you practice regularly. Recognise that people are different and they dont care to be like you.

If you read my posts you'd notice i dont care to know regex.
I would rather see a sermon than hear one any day. I'd rather have you walk with me, than merely point the way. The eye is a more ready pupil than ever was the ear, good advice is often confusing, but example is always clear.

- www.phpro.org
User avatar
JoshR
User
User
Posts: 716
Joined: Tue Jan 01, 2008 7:32 pm
Location: #mSL
Contact:

Postby JoshR » Thu Jan 01, 2009 4:32 pm

[quote="lovely3000"]
If you read my posts you'd notice i dont care to know regex.[/quote]

You will eventually, it can make your life easier in a lot of ways.

But just keep using what i told you

[code]

$start = strpos( $file,'<start spot>')+strlen('<start pos>');
$end = 'end spot';
$info = substr( $file, $start, strpos( $file, $end)-$start);

[/code]
Image

Return to “PHP”

Who is online

Users browsing this forum: No registered users and 1 guest