In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "python xpath reading attribute example analysis", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "python xpath read attribute example analysis" bar!
Climb the Douban movie page and find the data in the attribute tag. Use xpath to read import urllib.requestimport lxml.etree as leimport user_agentimport pandas as pd best_data = [] request = urllib.request.Request (url=' https://movie.douban.com/cinema/nowplaying/zhengzhou/', Headers= {'User-Agent':user_agent.get_user_agent_pc ()}) response = urllib.request.urlopen (request) html_x = le.HTML (response.read ()) sub_data = html_x.xpath (' / / ul [@ class= "lists"] / li') for i in sub_data: temp_data = {} temp_data ['number'] = '.join (i.xpath (' @ id') temp_) Data ['movie name'] = i.xpath ('@ data-title') temp_data ['movie score'] = i.xpath ('@ data-score') best_data.append (temp_data) pd.DataFrame (best_data). To_csv ('db.csv') xpath can crawl properties to this I believe that everyone has a deeper understanding of "python xpath read attribute example analysis", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.