Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GoGoogle($word, $file)
- {
- $h3 = "</br><h3 style=""text-align:center;background-color:blue;color:white;""> Google top page results </h3></br>"
- Add-Content $file $h3
- $urlG = 'http://www.google.com//search?q=' + $word + '&cad=h'
- $wreq = Invoke-WebRequest $urlG
- Start-Sleep -Seconds 1
- #get result links div
- $aList = $wreq.Links |where Href -ne $null |select -Property href
- foreach($a in $aList)
- {
- $a = [System.String]$a
- $dummy = ''
- for($c=2; $c -le $a.Length - 2; $c++)
- {
- $dummy += $a[$c]
- }
- $dummyStr = ''
- $dummyStr = "</br><a " + $dummy + ">Google link</a></br>"
- Add-Content $file $dummyStr
- }
- #set back to zero
- $wreq = $null
- $div = $null
- }
- function GoYoutube($word, $file)
- {
- $h3 = "</br><h3 style=""text-align:center;background-color:blue;color:white;""> Youtube top page video results </h3></br>"
- Add-Content $file $h3
- $urlY = 'https://www.youtube.com/results?search_query=' + $word + '+tutorial'
- Start-Sleep -Seconds 1
- #get result links div
- $wreq = Invoke-WebRequest $urlY
- $aList = $wreq.Links |where title -match $word |select -Property href
- foreach($aLink in $aList)
- {
- $a = [System.String]$aLink
- $a = $a.Insert($a.IndexOf("=") + 1, "http://youtube.com")
- $dummy = ''
- for($c=7; $c -le $a.Length - 2; $c++)
- {
- $dummy += $a[$c]
- }
- $dummy = "</br><a href=""{0}"">Youtube video link</a></br>" -f $dummy
- Add-Content $file $dummy
- }
- #set back to zero
- $wreq = $null
- $ol = $null
- }
- $date = Get-Date
- $date = "{0:dd_MM_yyyy}" -f [datetime]$date
- $file = 'C:\Users\evgeni.kostadinov\Desktop\webCrawlers\3-webResources\all\results-Google-Youtube-' + $date + '.html'
- $db = Get-Content 'C:\Users\evgeni.kostadinov\Desktop\webCrawlers\techsData.txt'
- for($k = 0; $k -le $db.Length - 1; $k++)
- {
- $searchKeyword = $db[$k]
- $h1 = "<h1 style=""text-align:center;background-color:red;color:white;""> " + $searchKeyword + "</h1>"
- Add-Content $file $h1
- #GoGoogle -word $searchKeyword -file $file
- GoYoutube -word $searchKeyword -file $file
- }
- start chrome $file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement