Fall 2005 Homework 5 Questions Page
does the homework need to have any inputs?
| Yes. There has been an adjustment to the assignment so that input is required. Sorry for the confusion. Kelly Lyons |
when is it due? next friday, right?
the last test avg was about a 70 something, will there be a curve or is there someway to earn points back on the test?
| There will be no curve on the test or on your final grade. If you have questions about your grade on specific questions (once you get the exam back), go see your TA. Amanda Bennett |
I am slightly confused with this assignment. Can it be links to any articles on the news sites or specifically the first 5? If I submitted the assignment early the news articles obviously wouldn't be the same as they would be on Friday Nov. 11th.
Nevermind I just read the last line about the headlines being different. Sorry
| Just for clarification: The assignment should grab the top 5 headlines from the site at the time the function is run in JES. Therefore when you run it before you turn it in, you'll get one set of headlines. When your TA grades it, he/she'll get a different set of headlines. The headlines must be the most recent top 5 from the site at the time it is run. DO NOT hard code headlines into your assignment. This is not what we are looking for and will result in a very poor grade. Kelly Lyons |
I just finished my code. Just so you know, on the CNN website, there's some funky html with a little video link that says "Watch" after the 4th headline. At least right now there is. My code won't look for headlines beyond this little "watch" button for some reason. The rest of the websites work fine.
| Yes there is the button watch but I think you should skip over it and go to the next text headline. -Albert d'Heurle |
economist = getEconomistNews()
cnn = getCNNNews()
wwn = getWeeklyWorldNews()
for num in range(5):
code = code + '<tr><td><b>' + economist[num] + '</b></td><td><i>' + cnn[num] + '</i></td><td><u>' + wwn[num] + '</u></td></tr>'
There's part of my code (I hope it's not too much). It keeps giving me this error for the "code = ..." line:
An attempt was made to call a function with a parameter of an invalid type. This means that you did something such as trying to pass a string to a method that is expecting an integer.
Can anyone tell me what I'm doing wrong? Thanks!
| Parameter of an invalid type means that something in that line is not a string. Go back and check what the values in your 3 lists are. Most likely one of them is not a string. Also make sure when you defined code, you defined it to be a string. Kelly Lyons |
| You also need to make sure that code is declared (code = ?????) before the for loop; otherwise you run into scope issues. Blake Israel |
The values for economist, cnn, and wwn are supposed to go to another function. I'm not really sure if they're a string or not...Do you think my functions are defined wrong and that's why it isn't reading them right? Also, I did define code earlier with html, etc. so that shouldn't be the problem. I really think it's something with the way I put in the other functions. Any advice or should I just email you my code? Thanks!
I have a problem with getting the href link off of the cnn website when there is extra stuff in front of the link. For instance, at 6:22 on Sunday, there is "SI.com:" and there is "Watch:" in front of 2 of the links. Are we to write our code to include for these specific anomilies or can we just assume the general format? –Thanks
In order to find each successive headline can we look for the previous headline found as a starting point to look for the next one? Like can I do:
end=cnn.find("",cnnhead1)
where cnnhead1 is the the first headline? I'm not sure if this will work right.
| Nope, you can't use the headline itself but you may want to try using something around the headline that won't change to base the next search off of. David Baxter |
this is kinda in the beginning of my code:
def hw5(directory):
file=open(directory,"wt")
file.write(doctype())
file.write('<head><title>"News Headlines"</titel></head>')
but jes keeps telling me that "hw5(directory)
I tried to read a file, and couldn't. Are you sure that file exists? If it does exist, did you specify the correct directory/folder?
Please check line 5 of C:\Documents and Settings\sunshine\My Documents\hw5"
and i did specify the correct folder. i have newfolder on my desktop called newsheadlines.html
and in the command area, i did directory=r'Cblah blah' then hw5(directory)
what did i do wrong?
| You aren't giving it a file to open. It should be file=open("aFileName.extension","wt"). Look at your last homework to see exactly how to write it. poof #10 |
The economist website won't allow us to use the html for this assignment. It has some blocking stuff at the end. We discovered this in Blake Isreal's and Jonny's recitation....so, what should we do?
Do we need to have a Meta tag or can we do with out it and get no points reduced?
| You do not need Meta tags in your assignment. Kelly Lyons |
are any other sites being blocked as well? My cnn headlines work and thats about it...If they are being blocked...is there an alternative?
| You can still pull headlines from Weekly World News without problems... I don't see any problem pulling headlines from the Economist either; the headlines under 'Global Agenda' are just as easy to parse as those on CNN. If you are running into trouble, make sure you get the URL http://www.economist.com/index.html rather than the root directory. The latter page contains some site setup stuff and a JavaScript redirect to the former, which is the one you want. – Matt Britt |
After running my program and viewing my page source, it shows that the headlines are in my table. However, when I view the page the only headlines that show up are the world weekly news headlines. Could this be due to the "blocking" that people are talking about?
Nevermind, I just fixed it by adding a before each of the headlines. I don't know why that worked.
Can we just skip the first headline on the economist site since it has that image block?
| No. You can do it very easily without having to worry about the image. poof #10 |
So can we use the Economist or not? Supposedly, it will not let us use it since we are not on a browser. That's what Blake and Jonny said.
| Use the three websites that it says to use in the instuctions. poof #10 |
ahh! last night i wrote code that worked fine, and now when i try to run it to get the headlines, i keep getting the message" A local name was used before it was created. You need to define the method or variable before you try to use it."- why is that????
We can't help you unless we see your code AND exactly what you typed in to get that error message. poof #10 |
for the economist, use the address http://www.economist.com/index.html and it will work just fine
| Correct. I think that is posted as the website to use. poof #10 |
on worldweeklynews.com after we search "breaking_news.gif"
do we start and end at a and because this is the only one that is not putting the headlines intot eh table whereas the others are wokring and have the same basic code
| look at the source code for worldweeklynews and look for the headlines. Then look for something that you could use. Amanda Bennett |
im aheving trouble how to make the links functional... i know that i need to add the first part...for example "http://cnn.com/" + "the rest"
can someone steer me in the right direction please
when i typed the code i get this respond from JES:
You are trying to access a part of the object that doesn't exist.
in file D:\CS1315\hw5\hw5.py, on line 3, in function hw5
in file C:\JES-SA1a\jython\Lib\urllib.py, on line 71, in function urlopen
in file C:\JES-SA1a\jython\Lib\urllib.py, on line 176, in function open
in file C:\JES-SA1a\jython\Lib\urllib.py, on line 283, in function open_http
in file C:\JES-SA1a\jython\Lib\httplib.py, on line 440, in function putrequest
AttributeError: __getitem__
Please check line 3 of D:\CS1315\hw5\hw5.py
i think that it can't recognize the url, what should i do?
I'm very confused about something. So my input for my function is a directory: hw5(directory)
so inside that directory, do i make another folder named newsheadlines.html? and once i do that do i, file=open(newsheadlines.html,"wt")?
What does "& n b s p ;" mean? (I had to put spaces between the characters otherwise it wouldn't appear)
I find it in headline tags on The Economist.
i have typed up my code but when i run it i get the same headline repeated 5 times. what do i need to change in order for there to be 5 different headlines this is what i have:
news.write("| CNN | The Economist | Weekly World News |
")
for number in range(0,5):
news.write("| " +findCnnNews()+ " | "+econ+ " | "+wwn+ " |
")
news.write('