[Tutor] Need help
Hi , I am new in python. Could you guys please help me here. I want to add every lebels value here (ie fetch from DB and display in front of every lebel or I had store every lable value in variable and display here). [image: Inline image 1] So that table looks like as follow [image: Inline image 2] Is there any function which I can use for this (like we have entry.get to get the value similar any function to put the value) Thanks in advance. Regards Niraj -- Success occurs when opportunity and preparation meet ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help
On 03/10/16 10:54, niraj pandey wrote: > I want to add every lebels value here (ie fetch from DB and display in > front of every lebel or I had store every lable value in variable and > display here). You need to tell us which OS, Python version and GUI toolkit you are using. > [image: Inline image 1] This is a text list so images usually get stripped off. If absolutely necessary to send an image use a link to an image gallery somewhere. But at least try to explain what you are trying to show us. > Is there any function which I can use for this (like we have entry.get to > get the value similar any function to put the value) Assuming you are using Tkinter there is an insert() method. To put text at the end of the entry use import tkinter as tk myText = "Hello world" top = tk.Tk() myEntry = tk.Entry(top) myEntry.pack() myEntry.insert(tk.END,mytext) top.mainloop() However a common alternative is to use a StringVar and associate it with the Entry so that changes in the StringVar are automatically shown in the Entry and changes in the Entrey are reflected to the StringVar. Most Tkinter tutorials will show that under StringVar. Of course if you are not using Tkinter most of that will be useless! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help
Hello Alan , I am using python 2.7.10 and using RHEL6 Thanks On Mon, Oct 3, 2016 at 8:53 PM, Alan Gauld via Tutor wrote: > On 03/10/16 10:54, niraj pandey wrote: > > > I want to add every lebels value here (ie fetch from DB and display in > > front of every lebel or I had store every lable value in variable and > > display here). > > You need to tell us which OS, Python version and GUI > toolkit you are using. > > > [image: Inline image 1] > > This is a text list so images usually get stripped off. > If absolutely necessary to send an image use a link to an > image gallery somewhere. > > But at least try to explain what you are trying to show us. > > > Is there any function which I can use for this (like we have entry.get to > > get the value similar any function to put the value) > > Assuming you are using Tkinter there is an insert() method. > To put text at the end of the entry use > > import tkinter as tk > myText = "Hello world" > top = tk.Tk() > > myEntry = tk.Entry(top) > myEntry.pack() > myEntry.insert(tk.END,mytext) > > top.mainloop() > > > However a common alternative is to use a StringVar and associate it with > the Entry so that changes in the StringVar are automatically > shown in the Entry and changes in the Entrey are reflected to the > StringVar. Most Tkinter tutorials will show that under StringVar. > > Of course if you are not using Tkinter most of that will be useless! > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Success occurs when opportunity and preparation meet ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] beautifulsoup
I am trying to scrap from the (span class= 'Number'). The code looks like this on the pages I am scrapping: 99 10.00(-0.1%) Menu Max Quantity 100.000 Average Quantity 822 Previous Order 96 Max Price 104 Number of Trades 383 Min Price 59 Total Amount 800 Start 10 Low 98 I have tried to use Beautifulsoup to scrape the data. However, it returns Nothing on the screen from bs4 import BeautifulSoup html = response.content soup = BeautifulSoup(html,"html.parser") title = soup.select('td.styleB')[0].next_sibling title1 = soup.find_all('span', attrs={'class': 'Number'}).next_sibling print(title1) I am hoping that I could retrieve the number as follows: Max Quantity: 100 Average Quantity: 822 Previous Order: 96 Max Price: 104 Number of Trades:383 Min Price: 59 Total Amount:800 Start:10 Low: 98 Please advise what is the problem with my code from handling the query. Thank you ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] beautifulsoup
On 04Oct2016 13:35, Crusier wrote: I am trying to scrap from the (span class= 'Number'). The code looks like this on the pages I am scrapping: 99 10.00(-0.1%) Menu Max Quantity 100.000 Average Quantity 822 Previous Order 96 Max Price 104 Number of Trades 383 Min Price 59 Total Amount 800 Start 10 Low 98 I have tried to use Beautifulsoup to scrape the data. However, it returns Nothing on the screen from bs4 import BeautifulSoup html = response.content soup = BeautifulSoup(html,"html.parser") title = soup.select('td.styleB')[0].next_sibling title1 = soup.find_all('span', attrs={'class': 'Number'}).next_sibling print(title1) I am hoping that I could retrieve the number as follows: Max Quantity: 100 Average Quantity: 822 Previous Order: 96 Max Price: 104 Number of Trades:383 Min Price: 59 Total Amount:800 Start:10 Low: 98 Please advise what is the problem with my code from handling the query. Thank you You perform several steps here before your print. Break them up. "soup.select", "[0]", "next_sibling" etc and print the intermediate values along the way. As a wide guess, might: title = soup.select('td.styleB')[0].next_sibling fetch this? I also suspect that next_sibling returns the next tags in the DOM tree. Not text. Your title1 might come out better as: title1 = str(soup.find_all('span', attrs={'class': 'Number'})[0]) if I recall how to grab the text inside a tag. Also, don't you want a loop around your find_all? Eg: for tag in soup.find_all('span', attrs={'class': 'Number'}): print(tag) print(str(tag)) # or tag.text() ? Anyway, put in more print()s in the middle of your traversal of the DOM. That should show where things are going wrong. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor