Created
October 5, 2016 15:19
-
-
Save cakriwut/37ed75512cf56214ef785daee3b10638 to your computer and use it in GitHub Desktop.
How to download URL news link from www.detik.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defines date range of the news | |
$startDate = Get-Date "2016-01-01" | |
$endDate = Get-Date | |
# Defines file capture location | |
$fileCapture = "C:\temp\detik.txt" | |
$detikApi = "http://apis.detik.com/v1/indeks?limit=500&channelid=10>={0:yyyy-MM-dd HH:mm:ss}<={1:yyyy-MM-dd HH:mm:ss}" | |
$currentDate = $startDate | |
do { | |
$nextDate = $currentDate.AddMonths(1) | |
# Format URL api | |
$uri = $detikApi -f $currentDate , $nextDate | |
# Shift to next day | |
$currentDate = $nextDate | |
$x = Invoke-WebRequest -Uri $uri -ContentType "application/json" | ConvertFrom-Json | |
$x.data | select -ExpandProperty Url | Add-Content $fileCapture | |
} while($currentDate -lt $endDate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ChannelId is valid from 1 - 12
This method is preferable compared to Detik.com's RSS feed. The RSS feeds only allow retrieval of 50 latest feed, without possibility to request more or request different date range.