Luyenkim.Net!

...where your idea grows!

 
  • Decrease font size
  • Default font size
  • Increase font size
Trang chủ arrow DIỄN ĐÀN
Luyện kim
Banner
Giải pháp lấy tin tự động từ các báo điện tử khác com_tintuc (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Giải pháp lấy tin tự động từ các báo điện tử khác com_tintuc
#874
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 697
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Giải pháp lấy tin tự động từ các báo điện tử khác com_tintuc 1 Year, 1 Month ago Karma: 5  
Link tải com_tintuc: download Info. Đây là bản đang sử dụng trên luyenkim.net đến ngày 14/10/2007.

Thông tin trao đổi xây dựng com_tintuc: Joomlaviet 4rum.

Demo:

Nguyên lý hoạt động:
  1. Công dụng của các file trong com_tintuc như sau:
    1. tintuc.php: đây là file dẫn hướng xử lý lựa chọn nhóm tin tức.
    2. tudong.class.php: là file thư viện chứa các hàm cần thiết, đừng sửa gì trong file này.
    3. tuoitre.php,thanhnien.php,dantri.php,tienphong.php: là các file hoạt động chính, lấy tin về. Nếu muốn chỉnh sửa về format, các bạn có thể chỉnh sửa các file này.
  2. Hoạt động thế nào:
    Bước 1: Get nội dung tin
    Bước 2: trích dẫn nội dung và xử lý đường link.
    Bước 3: Clear (Filter) các TAG không cần thiết
    Bước 4: kết xuất thông tin.


Tham khảo chính:


Các từ khóa chính:
+ Web fetching, content grabber

Sau đây là 1 ví dụ:
<?
$handle = fopen('http://www.', 'r' );

while (!feof($handle))
{
$html .= fread($handle, 4096);
}


$begin = '<table width="580" cellpadding="1" cellspacing="0" border="0" bgcolor="#FFFFFD" borderspacing="0">';
$end = '</table>';

$beginloc = strpos($html, $begin) + strlen($begin);
$endloc = strpos($html, $end);

$html = substr($html, $beginloc, $endloc - $beginloc);
echo "<table width=100%>";
$html = str_replace("</tr>", "</tr>\\n", $html);
$html = str_replace("</td>", "</td>\\n", $html);
$html = str_replace("<td width", "<td nowrap ", $html);
$html = str_replace("onMouseOver=\"this.style.cursor='hand'; window.status='Näheres zu dieser Stellenangebot'; return true;\" onMouseOut='window.status=\" \" ; return true;'","",$html);


echo $html;
echo "</table>";
?>
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.

Liên kết website

Thư viện cộng đồngvinaora.comthietbidien.vnLuyenkim.netTrung tam ho tro giao vien
#885
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 697
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Table Extractor - Any HTML table (almost) to a PHP Array, with advanced functions 1 Year, 1 Month ago Karma: 5  
source: reallyshiny.com

Ive just posted a new script to my website, it is called Table Extractor and it can extract almost any table from any html document/page, and then convert that html table into a php array.

Here are the features:
  • Can extract almost any table from any html page.
  • Uses the table column headers as the keys in the array.
  • Strip unnecessary html tags out of the source.
  • Limit the number of columns and rows returned, as well as set the start row and start column.
  • Create extra columns based on data in others using regular expressions, eg. The URL of a link.
  • Splits colspans and rowspans into their original number of cells.


I am sure that some parts of it could be greatly improved, if anyone has any suggestions please let me know, cheers.

The script is here.
And a guide explaining the features and how to use them is here.

Trang này đáng để nghiên cứu.


Xem thêm: đọc ảnh
http://www.nirvani.net/software/dr-fun/dr-fun-1.0.0.php.asc
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#896
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 697
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Trả lời: Giải pháp lấy tin tự động từ các báo điện tử khác com_tintuc 1 Year, 1 Month ago Karma: 5  
Rất vui được cộng tác với các bạn.

Hiện tại tôi cũng đã có 1 số ý tưởng cho com này và rất mong ai có thể viết code tham gia cùng phát triển - PM cho tôi nhé.

Thanks.

Update:
  1. Using Regular Expressions to get HTML tags
  2. http://www.getfreesofts.com/scriptscategory/10/103/1/0.html
  3. Web fetching content grabber-Tìm các từ khóa này.
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#940
nightwish_spb
(User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Trả lời: Giải pháp lấy tin tự động từ các báo điện tử khác com_tintuc 1 Year, 1 Month ago Karma: 0  
Mình là người mới học làm web sơ sơ thôi, nhưng mình thấy cách lấy tin của web các bạn rất hay, muốn học hỏi chút được ko? Các ban có thể hướng dẫn cụ thể hơn cách dùng component com_tintuc để lấy tin tự động từ các báo điện tử khác được không, vì mình cũng đã thử như các bạn hướng dẫn qua nhưng không đạt kết quả. Rất mong sự hồi âm,cảm ơn nhiều!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#969
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 697
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Cập nhật trang www.paper.edu.cn vào gói com_tintuc 1 Year, 1 Month ago Karma: 5  
Chuẩn bị bổ sung nội dung này vào com_tintuc:
  1. http://www.paper.edu.cn/en/index.php
  2. http://www.future.org.au/
  3. Cập nhật lại class news để có thể loại bỏ xử lý các link ngoài và link loại trừ như audio, video, file dữ liệu (pdf, download)....


Demo của _www.paper.edu.cn :
www.paper.edu.cn Free paper Online.


Demo về chức năng CACHE (bài của cuemkid-joomlaviet):
ví dụ nhé:
Code:

$url=mosgetparams($_REQUEST,'url','');

if(@filemtime($mosConfig_absolute_path.'/cache/'.md5($url))>3600*24*30)
{
$data=file_get_contents($mosConfig_absolute_path.'/cache/'.md5($url));
}else{
// Lấy tin từ báo theo biến url
// Định dạng .......
// ................ trả về nội dung trong biến $data
// và cuối cùng là:
$fp=fopen($mosConfig_absolute_path.'/cache/'.md5($url),'w+');
fwrite($fp,$data);
fclose($fp);
}

// echo $data; ...............

 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#984
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 697
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Trả lời: Cập nhật trang www.paper.edu.cn vào gói com_tintuc 1 Year, 1 Month ago Karma: 5  
Update Nov 9, 2007: đã bổ sung tính năng cache cho com_tintuc. Xóa 1 số TAG cho tin của Dantri.


Demo để tạo bản rút gọn:
http://quanphp.net/news/index.php

Một số hàm hay sử dụng:

$url = 'http://username:_password@hostname/path?arg=value#anchor';

echo parse_url($url);


Câu lệnh trên sẽ sinh:

Array
(
[scheme] => http
[host] => hostname
[user] => username
[pass] => _password
[path] => /path
[query] => arg=value
[fragment] => anchor
}



Xóa dấu cách kép:
$str = preg_replace('/\s\s+/', ' ', $str);


Thêm target="_blank" đối với liên kết.
Và thay địa chỉ email bằng liên kết mailto.

function hyperlink($text) {
// match protocol://address/path/file.extens...variable&another=asf%
$text = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*
[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])/i",
" $1$2", $text);
// match www.something.domain/path/file.exte...variable&another=asf%
$text = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*
[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])/i",
" $1$2", $text);
// match name@address
$text = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*
\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/i",
" $1$2", $text);
return $text;
}

 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#1038
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 697
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Trả lời: Cập nhật trang www.paper.edu.cn vào gói com_tintuc 1 Year ago Karma: 5  
Ngày 11/11/2007: tạo mới com_dynamicenglish để có thể link các bài học tiếng Anh từ VOA.
Bổ sung tính năng Menu cho các mục tin
Bắt đầu làm quen với preg_math và preg_math_all.
Kinh nghiệm sẽ được post ở đây:
images/fbfiles//files/textprocessing.txt
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#1042
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 697
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Trả lời: Cập nhật gói com_tintuc - com_tintuc Update on Nov 2007 1 Year ago Karma: 5  
Bản cài đặt mới nhất update ngày 11 tháng 11 năm 2007

com_tintuc_102



Nếu bạn đã cài đặt rồi, hãy sử dụng bản vá cho com_tintuc.
Bản pacth: copy file này vào thư mục gốc của Joomla 1.0.x, sau đó giải nén, nó sẽ tự copy file vào các thư mục của com_tintuc.
com_tintuc_102_patch

Demo:
http://luyenkim.net/home9/index.php...intuc&Itemid=88889190

Khắc phục sai Font trên báo Dantri Online.

Cập nhật ngày: 12/11/2007
+ Bổ sung American Idoms từ VOA để học tiếng Anh tiện lợi hơn.
+ Bổ sung tính năng hiển thị tiêu đề bài viết lên Website Title. Mới cho phần học tiếng Anh, sẽ bổ sung thêm tính năng này cho các phiên bản sau.

Cập nhật ngày: 13/11/2007
+ Bổ sung tính năng xem Video tại mục Cười của VNExpress.net
Demo .....
Giải thuật như sau:
Match các file media bằng preg_match_all, sau đó sử dụng preg_replace để thay thế phần thông báo lỗi phải có Flash. Cái code này loay hoay cả buổi chiều mới nghĩ ra đấy.
Demo (click here).

Cập nhật ngày: 14/11/2007
+ Đã tìm được cách fix sai $Itemid, xem com_dynamicenglish , từ nay có thể dã từ sai $Itemid .
+ _http://vivociti.com Có 1 số công cụ hỗ trợ khá thú vị! Đã download phần mềm của nó.

Cập nhật ngày 15/11/2007:
+ Hoàn thiện chức năng cache - sẽ cache long time đối với các article và 10 phút cho trang chủ index và sub content (tuơng dương Cat).

Cập nhật ngày 17/11/2007:
+ k0 nên sử dụng cache với md5 cách này k0 hay nếu số file cực lớn. Nên đưa về dạng rút gọn. Ví dụ: cache/tt/id_file
+ Đang xử lý http://www.paper.edu.cn từ đây sẽ chuyển sang hướng phân cấp hàm cho gọn:
get_item_content - nội dung bài viết
get_category - nhóm nội dung
get_index - trang nhất (trang chủ)
get_menu - lấy thông tin thực đơn - menu

Cập nhật ngày 19/11/2007:
+ bổ sung mã cho Nguoi lao động: http://quanphp.net/forum/viewtopic.php?t=36
+ Tuy nhiên hiện tại code trên vẫn bị thiếu TAG đóng gây nên sai sót 1 chút, sẽ fix sau.

Cập nhật ngày 20/11/2007:
+ Thêm TAG cho nld để hiển thị đúng Table.

Cập nhật 21/11/2007:
+ Thêm TAG cho nld hiển thị đúng hoàn toàn!
+ Gặp 1 lỗi phân tích link có chứa dấu cách:
Ví dụ: với link sau trong 1 trang web nào đó _http://luyenkim.net/abc/ght/uhn mk.mp3
Tôi bị lỗi này mất mấy ngày đối với com_dynamicenglish
Code tìm link trên như sau:

Chỉ vô tình sửa lại code chứ thực ra đâu có tìm đúng code như thế

Cập nhật 25/11/2007:
+ Bổ sung nguồn từ quản trị mạng - chạy cực nhanh.
+ @gmail: vấn đề ở đây không phải là link có dấu cách hay không mà do cách hiểu của bạn về hàm preg_match_all chưa đúng. Với pattern như bạn viết thì PRCE engine sẽ hiểu nó phải tìm ngay từ href= " đầu tiên nó gặp đến .mp3 gần nhất. Chứ không phải là tìm những cái href nào mà bắt đầu là href=" mà trong đó có .mp3
bạn phải xem lại pattern của mình.

Bạn xem thử ý tưởng này thế nào.
1. Tìm tất cả các href: '@href=["\'](.*?)["\']@'
2. Xem trong các href đó, nếu kết thúc là .mp3 thì đánh giá tiếp
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#1043
ktv
(User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Trả lời: Cập nhật gói com_tintuc - com_tintuc Update on Nov 11, 2007 1 Year ago Karma: 0  
Xin hỏi bạn là cái này có cài đc cho Joomla 1.5 ko?? cám ơn trc!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1046
gmail
(User)
Gold Boarder
Posts: 278
graphgraph
User Offline Click here to see the profile of this user
Birthdate: 1971-01-01
Trả lời: Cập nhật gói com_tintuc - com_tintuc Update on Nov 11, 2007 1 Year ago Karma: 1  
ktv viết:
Xin hỏi bạn là cái này có cài đc cho Joomla 1.5 ko?? cám ơn trc!

Hiện tại là chưa, nhưng nhóm sẽ bắt đầu phát triển cho Joomla 1.5 vào tháng 12/2007.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1048
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 697
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Trả lời: Giải pháp lấy tin tự động từ các báo điện tử khác com_tintuc 1 Year ago Karma: 5  
Source: title link - Nguồn: link của tiêu đề bài viết dưới đây:
Using the Alias as the Page Title for Joomla SEO
...
How did he do this? In Joomla content items you have the "Title" and the "Title Alias". Often people don't utilize the alias field, but with a little hacking you can add your super-duper meta title in the "Title Alias" field and still have your nice simple title on the page.

What do you need to do? Follow these five simple instructions:

1. OPEN components/com_content/content.php

2. LOOK FOR:

// page title
$mainframe->setPageTitle( $row->title );

3. CHANGE TO:

// If title alias title_alias) setPageTitle( $row->title );

}else{
$mainframe->setPageTitleAlias( $row->title_alias );
}
// END CODE SNIPPET

** NOTE: THIS MUST BE DONE IN 2 PLACES IN THE CONTENT.PHP FILE
4. OPEN includes/joomla.php file and look for:

function setPageTitle( $title=null ) {
if (@$GLOBALS['mosConfig_pagetitles']) {
$title = trim( htmlspecialchars( $title ) );
$title = stripslashes($title);
$this->_head['title'] = $title ? $GLOBALS['mosConfig_sitename'] . ' - '. $title : $GLOBALS['mosConfig_sitename'];
}
}

5. Add the following function AFTER this (note: do not replace the setPageTitle function):

// setPageTitleAlias - title of the content page to use tile_alias instead
/**
* @param string
*/
function setPageTitleAlias( $title_alias=null ) {
if (@$GLOBALS['mosConfig_pagetitles']) {
$title_alias = trim( htmlspecialchars( $title_alias ) );
$title_alias = stripslashes($title_alias);
$this->_head['title'] = $title_alias;
}
}

// END CODE SNIPPET
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#1050
nightwish_spb
(User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Trả lời: Cập nhật gói com_tintuc - com_tintuc Update on Nov 11, 2007 1 Year ago Karma: 0  
support viết:
Bản cài đặt mới nhất update ngày 11 tháng 11 năm 2007

com_tintuc_102



Nếu bạn đã cài đặt rồi, hãy sử dụng bản vá cho com_tintuc.
Bản pacth: copy file này vào thư mục gốc của Joomla 1.0.x, sau đó giải nén, nó sẽ tự copy file vào các thư mục của com_tintuc.
com_tintuc_102_patch

Demo:
http://luyenkim.net/home9/index.php...intuc&Itemid=88889190

Khắc phục sai Font trên báo Dantri Online.

Cập nhật ngày: 12/11/2007
+ Bổ sung American Idoms từ VOA để học tiếng Anh tiện lợi hơn.
+ Bổ sung tính năng hiển thị tiêu đề bài viết lên Website Title. Mới cho phần học tiếng Anh, sẽ bổ sung thêm tính năng này cho các phiên bản sau.


Làm ơn cho em hỏi là khi mình thao tác trên back-end thì làm thế nao để patch file vá com_tintuc_102_patch ah? Rất mong tận tình giải đáp, xin cảm ơn!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1052