Skip to content

Instantly share code, notes, and snippets.

@DanyWallace
Created February 12, 2024 14:47
Show Gist options
  • Save DanyWallace/937ee86f152e59245a7e537f4990c206 to your computer and use it in GitHub Desktop.
Save DanyWallace/937ee86f152e59245a7e537f4990c206 to your computer and use it in GitHub Desktop.
Automate your bing searches for points using selenium and google trends to get search queries
require "selenium-webdriver"
require "redis"
require "net/http"
# open up chromium, login to your bing account, then update the datadir bellow
data_dir_arg_1 = '--user-data-dir=C:\data\chromium.p\dany.lts'
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument(data_dir_arg_1)
driver = Selenium::WebDriver.for :chrome, options: options
driver.navigate.to "https://trends.google.com/trends/trendingsearches/daily?geo=US&hl=en-US"
sleep 2
top_searches = Array.new
driver.find_elements(class: "details-top").each { |b|
top_searches << b.text
}
puts "Top searches for today:\n#{top_searches}"
top_searches[0..10].each_with_index do |search, i|
driver.navigate.to "https://bing.com"
sleep rand(2..4)
driver.action.send_keys(search).perform
sleep rand(2..4)
driver.action.send_keys("\n").perform
sleep rand(5..9)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment