Hack Forums
[Python] retrieving data from tags - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] retrieving data from tags (/showthread.php?tid=5371344)



retrieving data from tags - IGotTheKeys - Aug 11, 2016

how do i retrieve the 68 from this tag using BeautifulSoup on python 3 ?any help would be greatly appreciated.

<a href="Website">London, United Kingdom<span class="temp">68&deg;</span><span class="icon i-3-s"></span></a>


* - SIM-1866423 - Aug 11, 2016

PHP Code

<?php 
import bs4


soup 
= bs4.BeautifulSoup('<a href="Website">London, United Kingdom<span class="temp">68&deg;</span><span class="icon i-3-s"></span></a>',"html.parser")
print  (
soup.find_all("span", class_="temp" )[0].contents[0]) 



* - domien - Aug 11, 2016

Please don't make double threads... https://hackforums.net/showthread.php?tid=5370621


* - IGotTheKeys - Aug 11, 2016

(Aug 11, 2016 11:36 AM)b3mb4m Wrote:  
PHP Code

<?php 
import bs4


soup 
= bs4.BeautifulSoup('<a href="Website">London, United Kingdom<span class="temp">68&deg;</span><span class="icon i-3-s"></span></a>',"html.parser")
print  (
soup.find_all("span", class_="temp" )[0].contents[0]) 

Yeah that works but it wont using requests with the data being on the website


* - Goodies - Aug 11, 2016

(Aug 11, 2016 02:32 PM)IGotTheKeys Wrote:  Yeah that works but it wont using requests with the data being on the website

Give us links and well give you code.


* - IGotTheKeys - Aug 12, 2016

(Aug 11, 2016 08:52 PM)Goodies Wrote:  Give us links and well give you code.
Thanks but i solved it now