Jump to content

[SOLVED] Odd Question but this is the best place to ask those :)


jp2b81

Recommended Posts

Ok so I have something I am trying to accomplish and I am not sure if it's possible

 

I am using a lot of different types of coding php, css, flash, html to name a few

 

What I am curious of is if there is a way to create a file that would read another website and lets say for example I wanted a particular part like a certain table's information to be read then created into a .txt file but with variable around it...

 

 

I'll try to give an example

 

 

We'll say the website has a section I have thats is coded like

 

<table><tr><td>HEY I'M THE INFORMATION HE WANTS</td></tr></table>

 

is there a way to have create something that will read the site and look for that specific section then take the text and put it in a text file with a variable for flash like

 

&varOne=HEY I'M THE INFORMATION HE WANTS&

 

If further explination is needed just ask I will try wasnt really sure how to explain it the big reason I want this is because I multiple different sites that ultimately have to get updated and its a very long process sometimes some of the information is the same but others isn't so I was hoping to be able to just update the one site and be good to go. I would just make the text file myself but some of the information that I want copied is generated already by other scripts

 

Thanks for your time

-Jp2b

Link to comment
Share on other sites

You would need to know the exact context of the data you want. You could use preg_match to grab data between <table> and </table>.

But what if there is more than one table in the page? Then you'd need preg_match_all() and know which table to grab. PHP is only as smart as you tell it to be. :)

 

Also, is there a specific format that this data is you're trying to retrieve? That might make things easier.

Is this data dynamic? Does it have a specific scheme? ...

 

Any more information will help us help you. :)

Link to comment
Share on other sites

I know this might sound strange but the information I am trying to grab is from my space so its all in html or css .... I do know the exact locations of the tables... I am making a design for myself to test but also making a design for a friend who wants to for whatever reason get his page to look like something different. (I think it defeats the point) but hey experience is experience. I don't want to get him a log to  my sites just to edit his text field so I am trying to just have him update things there and then be able to just go from there weather it be to an actual website or to his own my space page no matter what will work.

 

Does that help at all?

Link to comment
Share on other sites

$file=file("http://whatever");

may not be correct syntax.

since you are the author of the info we want to get, put the data between unique tags, like:

 

<--START_HERE-->

 

 

<--END_HERE-->

 

if you put them on their own line, you don't need preg stuff, just

 

for ($i=0; $i<count($file); $i++){

 if (trim($file[$i])=="<--START_HERE-->"){

   $i++;

   while (trim($file[$i])!="<--END_HERE-->"){

    $stuff+=$file[$i];

    $i++;

   }

 }

}

 

 

$stuff is a string of all your html you wanted to capture.

 

 

Link to comment
Share on other sites

$file=file("http://whatever");

may not be correct syntax.

since you are the author of the info we want to get, put the data between unique tags, like:

 

<--START_HERE-->

 

 

<--END_HERE-->

 

if you put them on their own line, you don't need preg stuff, just

 

for ($i=0; $i<count($file); $i++){

  if (trim($file[$i])=="<--START_HERE-->"){

    $i++;

    while (trim($file[$i])!="<--END_HERE-->"){

    $stuff+=$file[$i];

    $i++;

    }

  }

}

 

 

$stuff is a string of all your html you wanted to capture.

 

 

 

Cool that will work for the information you fill out now I just need something for the automated things ... you guys so rock :)

Link to comment
Share on other sites

$file=file("http://whatever");

may not be correct syntax.

since you are the author of the info we want to get, put the data between unique tags, like:

 

<--START_HERE-->

 

 

<--END_HERE-->

 

if you put them on their own line, you don't need preg stuff, just

 

for ($i=0; $i<count($file); $i++){

  if (trim($file[$i])=="<--START_HERE-->"){

    $i++;

    while (trim($file[$i])!="<--END_HERE-->"){

    $stuff+=$file[$i];

    $i++;

    }

  }

}

 

 

$stuff is a string of all your html you wanted to capture.

 

 

 

Only thing I am lost on is what to add to the code to get it to write the whatever.txt file ... keep in mind I am still sorta new to php but I have never been one to take it slow into things lol

Link to comment
Share on other sites

$file=file("http://whatever"); # this is input

may not be correct syntax.

since you are the author of the info we want to get, put the data between unique tags, like:

 

<--START_HERE-->

 

 

<--END_HERE-->

 

if you put them on their own line, you don't need preg stuff, just

$stuff="&varOne=";

for ($i=0; $i<count($file); $i++){

  if (trim($file[$i])=="<--START_HERE-->"){

    $i++;

    while (trim($file[$i])!="<--END_HERE-->"){

    $stuff.=$file[$i];

    $i++;

    }

  }

}

 

$stuff.="&";

 

fileputcontents($stuff,"yourtextfile.txt"); #this is output

 

again, I'm not looking at the manual, so check the syntax.

 

 

Link to comment
Share on other sites

Well just ask yourself: 'Has my question been answered?'.

 

It has for all of the information I have the ability to add the html comment tags to but with the automatic generated things I am confused still  ??? I think the biggest reason is I heard quite a few different things that said they should work but if I get something that will read and right for those things that doesnt make my brain hurt then yes it would be answered lol

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.