PHP - scraping google groups page - php

I am new to PHP, and i'm trying to get myself some data from a google groups page.
My goal is to get only the time, when was latest post released, but for testing here i'm trying at least get some data (posts). But when i launch my program, i won't get anything useful (just header file and saying i need to enable javascript, then reload the page, but i don't know how to deal with this)
$input_group = file_get_html('https://groups.google.com/forum/#!forum/comp.lang.php');
echo $input_group;
Then, if this will somehow work, i plan to use something like this for getting teh data. Maybye not the best solution tho. This worked for other pages, but for some reason not here.
foreach($input_group->find("someTagHere") as $a){
echo $a->plaintext;
}
Thanks.

Related

Web Scraping in php? need a specific piece of data

I'm trying to pull a piece of data from the website www.coinmarketcap.com
specifically, the market cap number up the top.
I've been trying to figure this out the past hour or so and have read MANY different ways people use these web scrapers but have not been successful at all. Could someone shed some light?
There are multiple ways, but the easiest is just take their url:
https://files.coinmarketcap.com/generated/stats/global.json
Please note: They might not like this. Maybe they dont want external parties to use their scripts. So also buidl a check wether the file still exists and doesnt give a 403 back.
How did I find this:
When the page loads,the header with the information loads after the document ready, so it can not have been made by the server and has to be AJAX.
Now we know that it is AJAX, we want to know which file. You do this by opening your browsers console. All browsers have a network tab, showing all resources being loaded. When you filter by XHR you see all AJAX request. Then you try to find the right one.

Database+Tooltip like wowhead

I´m searching a solution for this:
I want to have a series of pages where the information is provided on a single page like you see it here: http://www.wowhead.com/quest=12141
I want to have the information, which is on the page I've made, in a tooltip. Wowhead does it like this: http://www.wowhead.com/tooltips
I've tried the following:
I've made a MySQL database with my information in it and I'm able to print them out on the site.
Here is my problem. How do I get the informations inside of a tooltip. I can print them out with "php echo", but this would be a bit too complicated for general users to click on and wait for a page load to see them.
Summary: I need an easy solution to print out the information on a web site inside of a tooltip.
I hope you have any tips for me...
You can print all the content at once and show the tooltips using js without ajax requests.
I might misunderstood you and if yes - you should take some ajax tutorial

Pass php results to another website.

So what I am trying to do is this:
On my server users can put there YouTube channel name. My php file will then parse the channel and output HTML code with results. What I am looking to do is for the users to be able to put a code on there website that till call on my website lets say youtubevideos.com/videos.php?channel=channelname my code will take that name and output the videos back to there site. much like Google ads I guess.
Any idea how that is done, other than an iframe, I figured that will be my last resort.
I think what I'm looking for if for them to put a JavaScript on there site that will render as the HTML code I'm pushing from my php file.
Thank you!
The receiver code which is on the server you target need to set a header like that :
"Access-Control-Allow-Origin:*"
So, if you provide a service which need to exchange with your server & your code, is it possible. If you can't edit the targeted code & the header is not setted, it'll be impossible
There would be two parts of this solution.
In the videos.php file on your server, you would implement the logic to scrape the data from the original site and format it in the way you want to show on the final website.
For the end user, you would give a code similar to this that they would have to paste in their php pages to display the content from your site.
$your_website_url="http://youtubevideos.com/videos.php?channel=channelname";
//Don't forget the http:// at the start.
echo file_get_contents($your_website_url);
If file_get_contents() gives a security error, you can use curl.
I hope that helps.

Google Goal Tracking

I have a WordPress site with the CFormsII plugin installed using AJAX. I've been researching and trying to find out how to integrate Google event tracking code. I've found multiple examples but nothing that works.
About the closest I've gotten is finding the JavaScript code to call the event, I just can't find out where to put it
_gaq.push(['_trackPageview', '/cforms-goal/']);
I've tried echoing this out with script tags in the my-functions.php file in both my_cforms_ajax_filter($params) and my_cforms_action($cformsdata) but whenever I add in the echo statement, I receive the "One moment please..." And nothing gets submitted and the event isn't tracked.
I'm sure this is probably my lack of understanding of what's going on with the AJAX request. Maybe I can't echo out the JavaScript there? Maybe it boils down to how can I execute JavaScript code from the my-functions.php file?
I had the same problem and the solution I came up with was to create a new ok page and in core form admin/email options I checked Enable alternative success page, and I specified this new page as an alternative page.
Later, in google analytics I set up a new goal by url, setting this new page as a goal.
Hope it helps

get a facebooksource page

for one project, i need to get the facebook source page (html one) via a php application.
i try lot of method like curl, file_get_content, change my ini_set, etc.... but facebook never let me get the html result file.
Does anyone can help ?
for example this page :
ini_set('user_agent', $_SERVER['HTTP_USER_AGENT']);
$data = file_get_contents("http://apps.facebook.com/is_cool/?cafe_action=album&view=scroll",0);
Print strip_tags($data,"");
Thanks a lot.
Damien
Comment 1 :
- I need to create 2 application. I want to parse the html code to get some information from one to the other. I don't want to duplicate or take the facebook code. I just want to make a "view source" (like IE or firefox) and put it on a file, without ask my users. When my user is logged in my first application, i just want to is is credential to get the other content.
The reason you're having problems is that the majority of the facebook homepage content is loaded via AJAX. The data is not hardcoded into what your browser renders.
You should think of a different way to accomplish your goals. If you tell us a little more about what you're trying to do, we can probably help you find an alternate method.

Categories