[InstructablesBridge] Fix listCategories() to work with new layout
This commit is contained in:
parent
54fb29d443
commit
6f24987601
1 changed files with 21 additions and 13 deletions
|
@ -320,24 +320,32 @@ class InstructablesBridge extends BridgeAbstract {
|
||||||
* parameters list)
|
* parameters list)
|
||||||
*/
|
*/
|
||||||
private function listCategories(){
|
private function listCategories(){
|
||||||
// Use arbitrary category to receive full list
|
|
||||||
$html = getSimpleHTMLDOM(self::URI . '/technology/');
|
|
||||||
|
|
||||||
foreach($html->find('.channel a') as $channel) {
|
// Use home page to acquire main categories
|
||||||
$name = html_entity_decode(trim($channel->innertext));
|
$html = getSimpleHTMLDOM(self::URI);
|
||||||
|
$html = defaultLinkTo($html, self::URI);
|
||||||
|
|
||||||
// Remove unwanted entities
|
foreach($html->find('.home-content-explore-link') as $category) {
|
||||||
$name = str_replace("'", '', $name);
|
|
||||||
$name = str_replace(''', '', $name);
|
|
||||||
|
|
||||||
$uri = $channel->href;
|
// Use arbitrary category to receive full list
|
||||||
|
$html = getSimpleHTMLDOM($category->href);
|
||||||
|
|
||||||
$category = explode('/', $uri)[1];
|
foreach($html->find('.channel-thumbnail a') as $channel) {
|
||||||
|
$name = html_entity_decode(trim($channel->title));
|
||||||
|
|
||||||
if(!isset($categories)
|
// Remove unwanted entities
|
||||||
|| !array_key_exists($category, $categories)
|
$name = str_replace("'", '', $name);
|
||||||
|| !in_array($uri, $categories[$category]))
|
$name = str_replace(''', '', $name);
|
||||||
$categories[$category][$name] = $uri;
|
|
||||||
|
$uri = $channel->href;
|
||||||
|
|
||||||
|
$category_name = explode('/', $uri)[1];
|
||||||
|
|
||||||
|
if(!isset($categories)
|
||||||
|
|| !array_key_exists($category_name, $categories)
|
||||||
|
|| !in_array($uri, $categories[$category_name]))
|
||||||
|
$categories[$category_name][$name] = $uri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build PHP array manually
|
// Build PHP array manually
|
||||||
|
|
Loading…
Reference in a new issue