Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #infoworld
- $url = "http://www.infoworld.com/news"
- $result = Invoke-WebRequest $url
- Start-Sleep -Seconds 1
- $postDateTime = $result.AllElements | where Class -eq "publishDate" | select -First 15 -ExpandProperty innerText
- $count = 0
- foreach($date in $postDateTime)
- {
- if($date.Contains("PT"))
- {
- $count++
- }
- }
- $h1_a_list = $result.AllElements | where TagName -eq "h1" | select -First $count -ExpandProperty innerHTML
- $finalNews = "C:\Users\evgeni.kostadinov\Desktop\infoworld.html"
- if($count -ne 0)
- {
- #enter first post record
- Start-Sleep -Seconds 1
- $h1_a_list[0] = $h1_a_list[0].Insert($h1_a_list[0].IndexOf('href="')+6, "http://www.infoworld.com")
- $h1_a_list[0] + "</br>" > $finalNews
- for($i = 1; $i -le $h1_a_list.Length; $i++)
- {
- $h1_a_list[$i] = $h1_a_list[$i].Insert($h1_a_list[$i].IndexOf('href="')+6, "http://www.infoworld.com")
- $nextlink = ""
- $nextLink = $h1_a_list[$i] + "</br>"
- Add-Content $finalNews $nextLink
- }
- }
- Start-Sleep -Seconds 2
- start chrome $finalNews
- Start-Sleep -Seconds 3
- Remove-Item $finalNews
- #
- #itnews-software
- #
- $url = "http://www.itnews.com/software"
- $result = Invoke-WebRequest $url
- Start-Sleep -Seconds 1
- #cookies pop-up manually!
- $postDateTime = $result.AllElements | where Id -eq "date" | select -First 1 -ExpandProperty innerText
- $postDateTime = $postDateTime.Remove($postDateTime.IndexOf('|'))
- #leave only date
- $postDateTime = $postDateTime.Remove($postDateTime.IndexOf('2014')+ 4)
- $currDateTime = Get-Date
- $currDateTime = "{0:MMM dd, yyyy}" -f [datetime]$currDateTime
- if( $postDateTime -eq $currDateTime)
- {
- $linkPath = "C:\Users\evgeni.kostadinov\Desktop\itnews.txt"
- $h3_a = $result.AllElements | where TagName -eq "h3" | select -First 1 -ExpandProperty innerHTML > $linkPath
- }
- $link = Get-Content $linkPath
- $finalNews = "C:\Users\evgeni.kostadinov\Desktop\itnews.html"
- Start-Sleep -Seconds 2
- $link.Insert($link.IndexOf('href="')+6, "http://www.itnews.com") > $finalNews
- Remove-Item $linkPath
- start chrome $finalNews
- Start-Sleep -Seconds 3
- Remove-Item $finalNews
- #
- #itworld-news
- #
- $url = "http://www.itworld.com/news"
- $result = Invoke-WebRequest $url
- Start-Sleep -Seconds 1
- $postDateTime = $result.AllElements | where Class -eq "posted-date" | select -First 5 -ExpandProperty innerText
- $postDateTime[0] = $postDateTime[0].Substring(7, $postDateTime[0].Length-18)
- $postDateTime[1] = $postDateTime[1].Substring(7, $postDateTime[1].Length-18)
- $postDateTime[2] = $postDateTime[2].Substring(7, $postDateTime[2].Length-18)
- $postDateTime[3] = $postDateTime[3].Substring(7, $postDateTime[3].Length-18)
- $postDateTime[4] = $postDateTime[4].Substring(7, $postDateTime[4].Length-18)
- $currDateTime = Get-Date
- $currDateTime = "{0:MMM dd, yyyy}" -f [datetime]$currDateTime
- #read all post-datetime
- if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[0] )
- {
- $h3_a = $result.AllElements | where TagName -eq "h3" | select -First 5 -ExpandProperty innerHTML
- $finalNews = "C:\Users\evgeni.kostadinov\Desktop\itworld.html"
- Start-Sleep -Seconds 1
- $h3_a[0] = $h3_a[0].Insert($h3_a[0].IndexOf('href="')+6, "http://www.itworld.com")
- $h3_a[0] + "</br>" > $finalNews
- #get next post link
- if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[1] )
- {
- $h3_a[1] = $h3_a[1].Insert($h3_a[1].IndexOf('href="')+6, "http://www.itworld.com")
- $firstLink = $h3_a[1] + "</br>"
- Add-Content $finalNews $firstLink
- }
- #get next post link
- if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[2] )
- {
- $h3_a[2] = $h3_a[2].Insert($h3_a[2].IndexOf('href="')+6, "http://www.itworld.com")
- $secondLink = $h3_a[2] + "</br>"
- Add-Content $finalNews $secondLink
- }
- #get next post link
- if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[3] )
- {
- $h3_a[3] = $h3_a[3].Insert($h3_a[3].IndexOf('href="')+6, "http://www.itworld.com")
- $thirdLink = $h3_a[3] + "</br>"
- Add-Content $finalNews $thirdLink
- }
- #get next post link
- if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[4] )
- {
- $h3_a[4] = $h3_a[4].Insert($h3_a[4].IndexOf('href="')+6, "http://www.itworld.com")
- $fourthLink = $h3_a[4] + "</br>"
- Add-Content $finalNews $fourthLink
- }
- }
- Start-Sleep -Seconds 2
- start chrome $finalNews
- Start-Sleep -Seconds 3
- Remove-Item $finalNews
- #
- #computerworld
- #
- $url = "http://www.computerworld.com/news"
- $result = Invoke-WebRequest $url
- Start-Sleep -Seconds 1
- #cookies pop-up manually!
- $postLink = $result.AllElements | where Id -eq "first_article_header" | select -First 1 -ExpandProperty innerHTML
- $postLink = $postLink.Remove($postLink.IndexOf(">"))
- $postLink = $postLink.Substring($postLink.IndexOf("articleId="), $postLink.Length - $postLink.IndexOf("articleId="))
- $postLink = $postLink.Substring($postLink.IndexOf("="), $postLink.Length - $postLink.IndexOf("="))
- $postLink = $postLink.Substring(1, $postLink.Length - 2)
- $redirect = "http://www.computerworld.com/s/article/"
- $redirect += $postLink
- start chrome $redirect
- #
- #technews
- #
- $url = "http://technews.bg/article-category/software#.UzAhWyRBuCh"
- $result = Invoke-WebRequest $url
- Start-Sleep -Seconds 1
- $postDateTime = $result.AllElements | where Class -eq "date time published" | select -First 1 -ExpandProperty innerText
- if( $postDateTime -eq $currDateTime)
- {
- $linkPath = "C:\Users\evgeni.kostadinov\Desktop\technews.html"
- $h2_a = $result.AllElements | where Class -eq "entry-title" | select -First 1 -ExpandProperty innerHTML > $linkPath
- }
- Start-Sleep -Seconds 2
- start chrome $linkPath
- Start-Sleep -Seconds 2
- Remove-Item $linkPath
- #
- #blogs.telerik
- #
- $url = "http://blogs.telerik.com/"
- $result = Invoke-WebRequest $url
- #Start-Sleep -Seconds 3
- $postDateTime = $result.AllElements | where Class -eq "BlogPost-date" | select -First 1 -ExpandProperty datetime
- $currDateTime = Get-Date
- $currDateTime = "{0:yyyy-MM-dd}" -f [datetime]$currDateTime
- if( $postDateTime -eq $currDateTime)
- {
- $linkPath = "C:\Users\evgeni.kostadinov\Desktop\telerik-forums.txt"
- $h4_a = $result.AllElements | where TagName -eq "h4" | select -First 1 -ExpandProperty innerHTML > $linkPath
- }
- $link = Get-Content $linkPath
- $finalNews = "C:\Users\evgeni.kostadinov\Desktop\telerik-forums.html"
- $link.Insert($link.IndexOf('"')+1, "http://blogs.telerik.com/") > $finalNews
- Remove-Item $linkPath
- start chrome $finalNews
- Start-Sleep -Seconds 3
- Remove-Item $finalNews
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement