Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/RssFeed.php
  • Loading branch information
zoranbogoevski committed Mar 7, 2024
2 parents 213d0f7 + e4b0238 commit 576449e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ php artisan vendor:publish --provider="Kalimeromk\Rssfeed\RssFeedServiceProvider

This will publish a rssfeed.php config file to your config directory. Here you can set the XPaths for content elements.

```php
return [
'domain_xpaths' => [
[
'domain' => 'mistagogia.mk',
'content_element_xpaths' => [
'//div[@class="single_post"]',
],
],
],
'min_image_width' => 300,
'image_storage_path' => 'images',
];

```
### In this configuration file:

* domain_xpaths: Defines specific XPaths for content elements based on the domain. This allows for precise targeting of content within the RSS feed items for each domain.
* min_image_width: Sets the minimum width for images to be considered for storage, ensuring that only images of adequate size are saved.
* image_storage_path: Specifies the path where images from RSS feed items should be stored.
## Credits

This package was created by KalimeroMK.
Expand Down Expand Up @@ -78,3 +98,4 @@ use Kalimeromk\Rssfeed\Jobs\RssFeedJob;
$feedUrls = ['https://example.com/rss'];

RssFeedJob::dispatch($feedUrls);
```
18 changes: 12 additions & 6 deletions config/rssfeed.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?php

return [
'content_element_xpaths' => [
'//div[@class="post-content"]',
'//div[@class="article-body"]',
'//div[@class="td-post-content"]',
'//div[contains(concat(" ", normalize-space(@class), " "), " post-single-content ") and contains(concat(" ", normalize-space(@class), " "), " box ") and contains(concat(" ", normalize-space(@class), " "), " mark-links ")]',
'domain_xpaths' => [
[
'domain' => 'mistagogia.mk',
'content_element_xpaths' => [
'//div[@class="single_post"]',
],
],
],
];
'min_image_width' => 300,
'image_storage_path' => 'images',
];

7 changes: 2 additions & 5 deletions src/RssFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public function parseRssFeeds(array $feedUrls, $jobId = null): array
continue; // Skip this feedUrl if there's an error
}
}

return $parsedItems;
}

/**
* @param array $images
* @return array|bool
Expand Down Expand Up @@ -143,11 +145,6 @@ public function retrieveFullContent(string $postLink): bool|array
}






// The cURL fetching function from previous examples
private function fetchContentUsingCurl(string $url): bool|string
{
$ch = curl_init();
Expand Down

0 comments on commit 576449e

Please sign in to comment.