私がやりたいこと: http://reddit.com/r/worldnewsの一番上の投稿からテキストの見出しを取得し、そのテキストだけを持つ私の Web ページに出力します。
最後に、AppleScript cURL を使用して作成した Web ページからテキストを取得して出力したいと思います。
ボタンをクリックするとトップの投稿が表示されるスクリプトを作成しています。
編集何か考えられることがあれば、同じことをしたいと思いますが、Facebook の通知についてです。
編集PHP でサイトを取得してここに出力しています: http://colejohnsoncreative.com/personal/ai/worldnews.phpこれは私が使用しているコードです:
<?php
// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines = file('http://www.reddit.com/r/worldnews');
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
}
// Another example, let's get a web page into a string. See also file_get_contents().
$html = implode('', file('http://www.example.com/'));
// Using the optional flags parameter since PHP 5
$trimmed = file('somefile.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
?>
したがって、サイトのすべてのコードを出力しますが、プロジェクトに必要なのは
<a class="title " href="http://www.dailymail.co.uk/news/article-2219477/Cannabis-factory-couple-gave-400-000-drug-dealing-fortune-poor-Kenyans-jailed-years.html" >British couple who spent most of the money they made from canabis growing on paying for life changing operations and schooling for people in a poor Kenyan village gets sent to prison for 3 years.</a>
などなど、捨てる必要があるのですが、どうすれば捨てられますか?