Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
missing styntax
#1
This snippet of a test has some missing styntax, what are the missing codes where there is
**** ?



from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup

meetings_url = "http://www.racingzone.com.au/results/2018-03-10/"

meetings_client = uReq(meetings_url)
meetings_html = meetings_client.read()
meetings_client.close
meetings_soup = soup(meetings_html, "html.parser")
meetings = meetings_soup.findAll("td",****"class":"left"****)

filename = "Races.cvs"
f = open(filename, "w")

headers = "venue, link\n"
f.write(headers)

for meeting in meetings:
	venue = meeting.a.text
	meetings_link = "http://www.racingzone.com.au" + meeting.a["href"]

	f.write(venue + "," + meetings_link + "\n")
f.close()
In particular
meetings = meetings_soup.findAll("td",****"class":"left"****)
Thanks
Reply
#2
What do you think it is? Doesn't it ring a bell? Did you check docs for beautifulsoup?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Quote:surround python code with python tags, not quote tags.
I fixed this for you, so please use python tags on future posts,
Sorry, I forgot.

Quote:What do you think it is? Doesn't it ring a bell? Did you check docs for beautifulsoup?

I'm still very new at this...have no idea what to look for.

Thanks
Reply
#4
Ok, so it's 2 of those curly brackets, thanks to another forum.
meetings = meetings_soup.findAll("td",{"class":"left"})
You expected me to guess 2 curly brackets by reading 20 thousand volumes of RTFM Python tutorials in 6 months, just for 2 curly brackets ?


No wonder this world is retarded !
Reply
#5
(Jul-23-2018, 11:28 AM)bluedoor5 Wrote: You expected me to guess 2 curly brackets by reading 20 thousand volumes of RTFM Python tutorials in 6 months, just for 2 curly brackets ?
you should be able to guess the curly brackets after max 1 or 2 weeks into learning the language, when you are familiar with the main data structures in the language - "class":"left" suggest a dict, so...
or if you are lazy - after 15 minutes skimming trough beautifulsoup documentation where you can find similar examples.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
How dare you call me lazy, do you have a problem with your moderator status ?
I/we are ( plural ) am not of your era.
You "get" code, fine.
Some of us don't "get" code, but we do work at it at a pace most suitable.

You either answer the questions how it is asked and be of service
or piss off
Reply
#7
(Jul-23-2018, 12:25 PM)bluedoor5 Wrote: How dare you call me lazy, do you have a problem with your moderator status ?
'lazy' as in 'I don't want to learn 1-2 weeks, but for some 15 minutes I can look at the docs and get the answer'. No offense intended, however watch your language.
(Jul-23-2018, 12:25 PM)bluedoor5 Wrote: You either answer the questions how it is asked and be of service
or piss off
This is not how forum works. We will not do your homework. We guide you to find the answer yourself. This is the most helpful approach in long run - teaching you how to fish, instead of giving you fish. Either accept it or look for help elsewhere.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#8
Quote:teaching you how to fish, instead of giving you fish.

I needed to know the output of the file, once I see the file, then I can work backwards line by line on the code and decipher it.

I apologize for telling you to piss off, it will not happen again.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020