Created
July 20, 2020 21:34
-
-
Save HopperMCS/1fab507d105bcf29b4e4775bccf5f10a to your computer and use it in GitHub Desktop.
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
def self.search_by_query(query) | |
query_f = ERB::Util.url_encode("#{query}") | |
url = "https://newsapi.org/v2/everything?qInTitle=#{query_f}&pageSize=10&page=1&apiKey=#{self.api_public_key}" | |
req = URI.open(url) | |
response_body = req.read | |
json = JSON.parse(response_body) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment