ctcp Posted July 31, 2011 Share Posted July 31, 2011 how to copy from a website specific piece of txt and insert to mysql is any example or teturial about this ? i trying to search (google) but nothink for exmpale how to copy evry new post from there http://www.phpfreaks.com/forums/index.php?board=1.0 Thank you for your time. Quote Link to comment Share on other sites More sharing options...
cunoodle2 Posted July 31, 2011 Share Posted July 31, 2011 You could use fopen or php curl to read in the pages. From there you could use strpos or a variety of other items to get the text you want. Here is the code you could use for a twitter feed.. <?php $twitter_name = "phpfreaks"; $twitter_max = 5; $doc = new DOMDocument(); $doc->load('http://twitter.com/statuses/user_timeline.rss?screen_name='.$twitter_name); $twitter_counter = 0; foreach ($doc->getElementsByTagName('item') as $node) { //get the title and url of the twitter post $title = $node->getElementsByTagName('title')->item(0)->nodeValue; $url = $node->getElementsByTagName('link')->item(0)->nodeValue; $twitter_search_name = $twitter_name.": "; $pos = strpos($title, $twitter_search_name); //verify that the twitter post contains if ($pos !== false) { if ($pos == 0) { if ($twitter_counter < $twitter_max) { $title = str_replace($twitter_search_name,"", $title); echo "<a href=\"$url\" target=\"_blank\">$title</a><br />\n"; $twitter_counter++; } } } if ($twitter_counter >= $twitter_max) break; } ?> Quote Link to comment Share on other sites More sharing options...
ctcp Posted July 31, 2011 Author Share Posted July 31, 2011 them i need to read for strpos or a variety .. thank you mate Quote Link to comment Share on other sites More sharing options...
voip03 Posted July 31, 2011 Share Posted July 31, 2011 syntax error, unexpected '"' in $title = str_replace($twitter_search_name," ", $title); thanks Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 31, 2011 Share Posted July 31, 2011 syntax error, unexpected '"' in $title = str_replace($twitter_search_name," ", $title); thanks There was no error in that code to begin with. Quote Link to comment Share on other sites More sharing options...
IrOnMaSk Posted August 1, 2011 Share Posted August 1, 2011 how to copy from a website specific piece of txt and insert to mysql the easiest way is in 5 steps 1) to place your mouse pointer at the beginning of where you want to copy, hold the left click and drag the mouse over the text you want to copy and stop at the end of where you don't want the text anymore. 2) Release the mouse, you should see the text highlight, make sure that all the text you want. 3) press and hold Ctrl and press letter C at same time. 4) go to your mysql database table and place the mouse where you want to paste the text to. 5) press and hold Ctrl and press letter V... Done forgive me, if that's not the way you want to do it... it's just one of the possibilities Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 2, 2011 Share Posted August 2, 2011 IrOnMaSk copy and past forgive me, if that's not the way you want to do it... it's just one of the possibilities that g8 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.