I used the code given via SoundCloud:
This is the error in my terminal results read:
I can't figure out what I did wrong.. :\
This is the result of when I type just "puts tracks"
You can see where the next_href is displayed at the bottom.
If you take a look at the data returned, it might be that it is in a sub-property called "collection", so the correct iterator is "tracks.collection.each"
Related
I am using PRAW to scrape data off of reddit. I am using the .search method to search very specific people. I can easily print the title of the submission if the keyword is in the title, but if the keyword is in the text of the submission nothing pops up. Here is the code I have so far.
import praw
reddit = praw.Reddit(----------)
alls = reddit.subreddit("all")
for submission in alls.search("Yoa ming",sort = comment, limit = 5):
print(submission.title)
When I run this code i get
Yoa Ming next to Elephant!
Obama's Yoa Ming impression
i used to yoa ming... until i took an arrow to the knee
Could someone make a rage face out of our dearest Yoa Ming? I think it would compliment his first one so well!!!
If you search Yoa Ming on reddit, there are posts that dont contain "Yoa Ming" in the title but "Yoa Ming" in the text and those are the posts I want.
Thanks.
You might need to update the version of PRAW you are using. Using v6.3.1 yields the expected outcome and includes submissions that have the keyword in the body and not the title.
Also, the sort=comment parameter should be sort='comments'. Using an invalid value for sort will not throw an error but it will fall back to the default value, which may be why you are seeing different search results between your script and the website.
everyone. I'm working with the Search Console API. I'm authenticated and getting data -- but not all that I'm hoping for.
The docs say that I can request 5,000 rows at a time. But when I set the setrowLimit parameter like this:
$request->setRowLimit(5000);
I get 127 rows returned, with text at the very bottom of the result set that says 'more elements...' -- almost as if it's a paginated result set.
How do I get to those 'more elements'?
Edit: At the top of my result set, I see this response;
array (size=5000)
So it definitely appears there are 5,000 results in the array, I just don't know how to get them all.
Please, post an example of your code. I set row limit to 5000 bit i don't have any problemi and never see the label "more elements". Where do you get this text? Into the array result?
I am trying to debug some code on parse.com. I am using console.log to print to console various things but when I try to read the log file all I get is the Input and the Result. This is what I have tried so far
console.log("whatever") //nothing
console.warn("whatever") //nothing
In the terminal
parse log -l INFO //This gives me just Input and Result
Anyone knows how to do this?
Thanks in advance.
You need to pass a JSON string, not a regular string. For example: console.log({"hello":"world!"});
I can't find the reference, and even they use normal string in their example code, but it works fine with JSON strings.
I need to use Google Spreadsheet ImportXML return a value from this website...
http://www.e-go.com.au/calculatorAPI2?pickuppostcode=2000&pickupsuburb=SYDNEY+CITY&deliverypostcode=4000&deliverysuburb=BRISBANE&type=Carton&width=40&height=35&depth=65&weight=2&items=3
the website simply displays the below in text and code...
error=OK
eta=Overnight
price=64.69
I need to return the values after last line 'price=', being a newbee I'm struggling with xpath query (?) required to make this happens...
=importxml("url",?)
Your help is greatly appreciated.
Thank you in advance.
Regards
first of all, IMPORTXML() won't work because your webpage is not formatted correctly for XML, and google sheets doesn't like it.
All hope is not lost tho, as your output is so simple. you can simply load the whole output using IMPORTDATA() and then process within google sheets
have a look at the output of the following formulae (where the url is stored in A1)
=IMPORTDATA(A1)
=transpose(IMPORTDATA(A1))
=index(IMPORTDATA(A1),3,1) - IF there are always 3 results, and price will always be in the third one this will work
=filter(IMPORTDATA(A1),left(IMPORTDATA(A1),5)="price") - if the price can appear in any of the result lines, but always starting with "price"
I am trying to check to see if text is present using Selenium 2 and Firefox but cant seem to find the method to use. I tried to use the method is_text_present which seems to be what everyone says work but will not work for me. I get the returned error:
NoMethodError: undefined method `is_text_present' for# Selenium::WebDriver::Driver:0x1017232e0 browser=:firefox
How do you check the page for text using Selenium 2 and Firefox?
When I tried this stack overflow option "Finding text in page with selenium 2" it did not work for me, I believe it doesn't work because I am using Ruby to do my test, not Java.
If you don't know in which element should be your text, you can use :
driver.page_source.include? 'TEXT_TO_SEARCH'
Otherwise you can use as Llelong and Thomp suggested :
driver.find_element(:id=>"ELEMENT_ID").text.include? 'TEXT_TO_SEARCH'
driver.find_element(:class=>"ELEMENT_CLASS").text.include? 'TEXT_TO_SEARCH'
You can find the text in JAVA using the following code snippet...
Try using the same for Ruby:-
driver.getPageSource().contains("TEXTTOSEARCH");
require 'selenium-webdriver'
br = Selenium::WebDriver.for :firefox
br.get "http://cnn.com"
br.find_element(:id=>"cnnMainPage")
br.find_element(:id=>"cnnMainPage").text.include? "Mideast"
I tested this in the irb, so you may run into timing problems (may have to wait for the element to be present first).
I'm not sure how to do it in Ruby, but you should be able to call the getPageSource() method, and check to see if that contains the string of text you're looking for.
If you can't find the text in the source, you probably want to identify the exact element that contains the text and call the getText() method on that element. For example, these are some common identifiers for elements:
driver.findElement(By.xpath("xpathstring")).getText()
driver.findElement(By.className("className")).getText()
driver.findElement(By.name("elementname")).getText()
driver.findElement(By.id("idname")).getText()
There are several more element identifiers, you'll have to consult the documentation if these don't work for you.
this worked for me...
driver.page_source.should_not include 'Login failed'