Advertisement
ekostadinov

Assembled and customized news reports

Aug 18th, 2014
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.25 KB | None | 0 0
  1. #infoworld
  2. $url = "http://www.infoworld.com/news"
  3. $result = Invoke-WebRequest $url
  4. Start-Sleep -Seconds 1
  5. $postDateTime = $result.AllElements | where Class -eq "publishDate" | select -First 15 -ExpandProperty innerText
  6. $count = 0
  7. foreach($date in $postDateTime)
  8. {
  9. if($date.Contains("PT"))
  10. {
  11. $count++
  12. }
  13. }
  14. $h1_a_list =  $result.AllElements | where TagName -eq "h1" | select -First $count -ExpandProperty innerHTML
  15. $finalNews = "C:\Users\evgeni.kostadinov\Desktop\infoworld.html"
  16. if($count -ne 0)
  17. {
  18. #enter first post record
  19. Start-Sleep -Seconds 1
  20. $h1_a_list[0] = $h1_a_list[0].Insert($h1_a_list[0].IndexOf('href="')+6, "http://www.infoworld.com")
  21. $h1_a_list[0] + "</br>" > $finalNews
  22. for($i = 1; $i -le $h1_a_list.Length; $i++)
  23. {
  24. $h1_a_list[$i] = $h1_a_list[$i].Insert($h1_a_list[$i].IndexOf('href="')+6, "http://www.infoworld.com")
  25. $nextlink = ""
  26. $nextLink = $h1_a_list[$i] + "</br>"
  27. Add-Content $finalNews $nextLink
  28. }
  29. }
  30. Start-Sleep -Seconds 2
  31. start chrome $finalNews
  32. Start-Sleep -Seconds 3
  33. Remove-Item $finalNews
  34. #
  35. #itnews-software
  36. #
  37. $url = "http://www.itnews.com/software"
  38. $result = Invoke-WebRequest $url
  39. Start-Sleep -Seconds 1
  40. #cookies pop-up manually!
  41. $postDateTime = $result.AllElements | where Id -eq "date" | select -First 1 -ExpandProperty innerText
  42. $postDateTime =  $postDateTime.Remove($postDateTime.IndexOf('|'))
  43. #leave only date
  44. $postDateTime = $postDateTime.Remove($postDateTime.IndexOf('2014')+ 4)
  45. $currDateTime =  Get-Date
  46. $currDateTime = "{0:MMM dd, yyyy}" -f [datetime]$currDateTime
  47. if( $postDateTime -eq $currDateTime)
  48. {
  49. $linkPath = "C:\Users\evgeni.kostadinov\Desktop\itnews.txt"
  50. $h3_a =  $result.AllElements | where TagName -eq "h3" | select -First 1 -ExpandProperty innerHTML > $linkPath
  51. }
  52. $link = Get-Content $linkPath
  53. $finalNews = "C:\Users\evgeni.kostadinov\Desktop\itnews.html"
  54. Start-Sleep -Seconds 2
  55. $link.Insert($link.IndexOf('href="')+6, "http://www.itnews.com") > $finalNews
  56. Remove-Item $linkPath
  57. start chrome $finalNews
  58. Start-Sleep -Seconds 3
  59. Remove-Item $finalNews
  60. #
  61. #itworld-news
  62. #
  63. $url = "http://www.itworld.com/news"
  64. $result = Invoke-WebRequest $url
  65. Start-Sleep -Seconds 1
  66. $postDateTime = $result.AllElements | where Class -eq "posted-date" | select -First 5 -ExpandProperty innerText
  67. $postDateTime[0] = $postDateTime[0].Substring(7, $postDateTime[0].Length-18)
  68. $postDateTime[1] = $postDateTime[1].Substring(7, $postDateTime[1].Length-18)
  69. $postDateTime[2] = $postDateTime[2].Substring(7, $postDateTime[2].Length-18)
  70. $postDateTime[3] = $postDateTime[3].Substring(7, $postDateTime[3].Length-18)
  71. $postDateTime[4] = $postDateTime[4].Substring(7, $postDateTime[4].Length-18)
  72. $currDateTime =  Get-Date
  73. $currDateTime = "{0:MMM dd, yyyy}" -f [datetime]$currDateTime
  74. #read all post-datetime
  75. if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[0] )
  76. {
  77. $h3_a =  $result.AllElements | where TagName -eq "h3" | select -First 5 -ExpandProperty innerHTML
  78. $finalNews = "C:\Users\evgeni.kostadinov\Desktop\itworld.html"
  79. Start-Sleep -Seconds 1
  80. $h3_a[0] = $h3_a[0].Insert($h3_a[0].IndexOf('href="')+6, "http://www.itworld.com")
  81. $h3_a[0] + "</br>" > $finalNews
  82. #get next post link
  83. if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[1] )
  84. {
  85. $h3_a[1] = $h3_a[1].Insert($h3_a[1].IndexOf('href="')+6, "http://www.itworld.com")
  86. $firstLink = $h3_a[1] + "</br>"
  87. Add-Content $finalNews $firstLink
  88. }
  89. #get next post link
  90. if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[2] )
  91. {
  92. $h3_a[2] = $h3_a[2].Insert($h3_a[2].IndexOf('href="')+6, "http://www.itworld.com")
  93. $secondLink = $h3_a[2] + "</br>"
  94. Add-Content $finalNews $secondLink
  95. }
  96. #get next post link
  97. if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[3] )
  98. {
  99. $h3_a[3] = $h3_a[3].Insert($h3_a[3].IndexOf('href="')+6, "http://www.itworld.com")
  100. $thirdLink = $h3_a[3] + "</br>"
  101. Add-Content $finalNews $thirdLink
  102. }
  103. #get next post link
  104. if( [System.DateTime]$currDateTime -eq [System.DateTime]$postDateTime[4] )
  105. {
  106. $h3_a[4] = $h3_a[4].Insert($h3_a[4].IndexOf('href="')+6, "http://www.itworld.com")
  107. $fourthLink = $h3_a[4] + "</br>"
  108. Add-Content $finalNews $fourthLink
  109. }
  110. }
  111. Start-Sleep -Seconds 2
  112. start chrome $finalNews
  113. Start-Sleep -Seconds 3
  114. Remove-Item $finalNews
  115. #
  116. #computerworld
  117. #
  118. $url = "http://www.computerworld.com/news"
  119. $result = Invoke-WebRequest $url
  120. Start-Sleep -Seconds 1
  121. #cookies pop-up manually!
  122. $postLink = $result.AllElements | where Id -eq "first_article_header" | select -First 1 -ExpandProperty innerHTML
  123. $postLink = $postLink.Remove($postLink.IndexOf(">"))
  124. $postLink = $postLink.Substring($postLink.IndexOf("articleId="), $postLink.Length - $postLink.IndexOf("articleId="))
  125. $postLink = $postLink.Substring($postLink.IndexOf("="), $postLink.Length - $postLink.IndexOf("="))
  126. $postLink = $postLink.Substring(1, $postLink.Length - 2)
  127. $redirect = "http://www.computerworld.com/s/article/"
  128. $redirect += $postLink
  129. start chrome $redirect
  130. #
  131. #technews
  132. #
  133. $url = "http://technews.bg/article-category/software#.UzAhWyRBuCh"
  134. $result = Invoke-WebRequest $url
  135. Start-Sleep -Seconds 1
  136. $postDateTime = $result.AllElements | where Class -eq "date time published" | select -First 1 -ExpandProperty innerText
  137. if( $postDateTime -eq $currDateTime)
  138. {
  139. $linkPath = "C:\Users\evgeni.kostadinov\Desktop\technews.html"
  140. $h2_a =  $result.AllElements | where Class -eq "entry-title" | select -First 1 -ExpandProperty innerHTML > $linkPath
  141. }
  142. Start-Sleep -Seconds 2
  143. start chrome $linkPath
  144. Start-Sleep -Seconds 2
  145. Remove-Item $linkPath
  146. #
  147. #blogs.telerik
  148. #
  149. $url = "http://blogs.telerik.com/"
  150. $result = Invoke-WebRequest $url
  151. #Start-Sleep -Seconds 3
  152. $postDateTime = $result.AllElements | where Class -eq "BlogPost-date" | select -First 1 -ExpandProperty datetime
  153. $currDateTime =  Get-Date
  154. $currDateTime = "{0:yyyy-MM-dd}" -f [datetime]$currDateTime
  155. if( $postDateTime -eq $currDateTime)
  156. {
  157. $linkPath = "C:\Users\evgeni.kostadinov\Desktop\telerik-forums.txt"
  158. $h4_a =  $result.AllElements | where TagName -eq "h4" | select -First 1 -ExpandProperty innerHTML > $linkPath
  159. }
  160. $link = Get-Content $linkPath
  161. $finalNews = "C:\Users\evgeni.kostadinov\Desktop\telerik-forums.html"
  162. $link.Insert($link.IndexOf('"')+1, "http://blogs.telerik.com/") > $finalNews
  163. Remove-Item $linkPath
  164. start chrome $finalNews
  165. Start-Sleep -Seconds 3
  166. Remove-Item $finalNews
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement