Giter VIP home page Giter VIP logo

Comments (6)

amrrs avatar amrrs commented on August 22, 2024

Hey Thanks for raising the issue here. Can you share the entire code that you used to try? just the scraping part

from build_tools_to_automate_python.

tsamlama avatar tsamlama commented on August 22, 2024

Hey Thanks for raising the issue here. Can you share the entire code that you used to try? just the scraping part

def extract_news(url):
print('Extracting Hacker news Stories...')
cnt=''
cnt +=('<b>HN Top Stories:</b>\n'+'<br>'+'-'*50+'<br>')
response = requests.get(url)
content = response.content
soup = BeautifulSoup(content, 'html.parser')
for i, tag in enumerate(soup.find_all('td', attrs={'class':'title','valign':''})):
cnt += ((str(i+1)+' :: '+tag.text + "\n" + '<br>') if tag.text!='More' else '')
return (cnt)

cnt = extract_news('https://news.ycombinator.com/')
content += cnt
content += ('<br>------</br>')
content += ('<br><br>End of Message')

from build_tools_to_automate_python.

ODubDubH3 avatar ODubDubH3 commented on August 22, 2024

You need to indent line 9, cnt+=((str(i+1)..., otherwise the loop ends after the first iteration.

from build_tools_to_automate_python.

amrrs avatar amrrs commented on August 22, 2024

Thanks @ODubDubH3 for the comment. Appreciate it. I seemed to have missed this!

from build_tools_to_automate_python.

ODubDubH3 avatar ODubDubH3 commented on August 22, 2024

from build_tools_to_automate_python.

amrrs avatar amrrs commented on August 22, 2024

Thank you @ODubDubH3 I'm trying to post more Automation videos - https://www.youtube.com/playlist?list=PLpdmBGJ6ELUIDexUW-_hgz1JA86aAT7eZ

Check it out when you get time, Always up for feedback and improvements!

from build_tools_to_automate_python.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.