lib/twitterscraper/query.rb in twitterscraper-ruby-0.15.0 vs lib/twitterscraper/query.rb in twitterscraper-ruby-0.15.1
- old
+ new
@@ -25,12 +25,12 @@
INIT_URL_USER = 'https://twitter.com/__USER__'
RELOAD_URL_USER = 'https://twitter.com/i/profiles/show/__USER__/timeline/tweets?' +
'include_available_features=1&include_entities=1&' +
'max_position=__POS__&reset_error_state=false'
- def build_query_url(query, lang, from_user, pos)
- if from_user
+ def build_query_url(query, lang, type, pos)
+ if type == 'user'
if pos
RELOAD_URL_USER.sub('__USER__', query).sub('__POS__', pos.to_s)
else
INIT_URL_USER.sub('__USER__', query)
end
@@ -49,11 +49,11 @@
proxy = proxies.sample
logger.info("Using proxy #{proxy}")
end
Http.get(url, headers, proxy, timeout)
rescue => e
- logger.debug "query_single_page: #{e.inspect}"
+ logger.debug "get_single_page: #{e.inspect}"
if (retries -= 1) > 0
logger.info "Retrying... (Attempts left: #{retries - 1})"
retry
else
raise Error.new("#{e.inspect} url=#{url}")
@@ -77,10 +77,10 @@
def query_single_page(query, lang, type, pos, headers: [], proxies: [])
logger.info "Querying #{query}"
query = ERB::Util.url_encode(query)
- url = build_query_url(query, lang, type == 'user', pos)
+ url = build_query_url(query, lang, type, pos)
http_request = lambda do
logger.debug "Scraping tweets from #{url}"
get_single_page(url, headers, proxies)
end