Hello there! In this post I am going to show you how we can extract all urls from a webpage with php. For this purpose I am using php DOMDocument object. It is a awesome tools for working with DOM elements. If you are familiar with JavaScript you can found many similarity between them.
Let's see how we can extract url from a webpage with php.
<?php // get data from url $data = file_get_contents('http://wwww.w3bees.com'); $dom = new DOMDocument; // load html with error handler @$dom->loadHTML($data); // find all a tags $anchors = $dom->getElementsByTagName('a'); $url = array(); foreach ($anchors as $anchor) { // get href value $href = $anchor->getAttribute('href'); // filter valid urls if (!preg_match("/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/", $href) ) continue; $url[] = $href; } var_dump($url); ?>
địa chỉ học kế toán
ReplyDeletekhóa học kế toán dành cho giám đốc
dịch vụ thành lập doanh nghiệp công ty trọn gói giá rẻ
trung tâm đào tạo kế toán tại hải dương
trung tâm đào tạo kế toán tại đồng nai
lớp học kế toán tại đồng nai
học kế toán thực hành tại vinh nghệ an
học kế toán thực hành tại quận 9
học kế toán thực hành tại vĩnh phúc
học kế toán thực hành hưng yên
học kế toán thực hành tại phú thọ
học kế toán thực hành tại bà rịa vũng tàu
trung tâm đào tạo kế toán tại quận 3 tphcm>học kế toán thực hành tại quận 3
học kế toán thực hành tại đà nẵng
học kế toán thực hành tại huế
lớp học kế toán tổng hợp tại đà nẵng
lớp học kế toán tổng hợp tại huế
học kế toán thực hành tại vinh nghệ an
học kế toán thực hành tại đà nẵng
học kế toán thực hành tại bà rịa vũng tàu
học kế toán thực hành tại huế
khóa học kế toán dành cho người mới bắt đầu
khóa học kế toán dành cho người đã học kế toán
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeletePHP Training in chennai | PHP Training Course
PHP Training in chennai | Online PHP Course
Nice article thanks for sharing , very informative and insightful stuff , keep updating more
ReplyDeletered hat linux training in chennai | rhce certification in chennai | red hat certification training in chennai
check ou mba result
ReplyDeleteneet result 2019
ncert solutions class 11 maths straight lines
ReplyDeleteتنظيف منازل بالدمام شركة تنظيف
تنظيف منازل بالاحساء شركة تنظيف منازل بالاحساء
تنظيف منازل بمكة شركة تنظيف منازل بمكة
تنظيف منازل بجدة شركة تنظيف منازل بجدة
تنظيف منازل بالمدينة المنورة شركة تنظيف المنازل بالمدينة المنورة
thank you so
ReplyDeleteدانلود اهنگ
محمد معتمدی تمام خاطرات من
غلامرضا صنعتگر اشک زلال