Page 115 - 高中 信息技术 必修1 数据与计算
P. 115

 5.2 数据的采集







                         (2)爬取商品标题。


                           all_title = soup.find_all('a', class_=re.compile("history-item product"))

                                   for j in all_title:
                                       soup_title = bs4.BeautifulSoup(str(j), "html.parser")
                                       title.append(soup_title.a['title'])



                         (3)爬取商品价格。


                           all_price = soup.find_all('span', itemprop="price")
                                             广东教育出版社
                                   for k in all_price:
                                       soup_price = bs4.BeautifulSoup(str(k), "html.parser")
                                       price.append(soup_price.span.string)



                         (4)爬取商品订单量。


                          all_order = soup.find_all('a', class_=re.compile("order-num-a"))
                                  for l in all_order:

                                      soup_order = bs4.BeautifulSoup(str(l), "html.parser")
                                      order.append(soup_order.em.string)



                         (5)爬取出售商品的店铺名称。



                          all_store = soup.find_all('div', class_="store-name util-clearfix")
                                  for m in all_store:
                                      soup_store = bs4.BeautifulSoup(str(m), "html.parser")

                                      store.append(soup_store.a.string)


                         3.其他数据采集法

                         对于企业生产经营或科学研究等保密性要求较高的数据,可通过与企业或研究机构合
                    作,使用特定系统接口等相关方式收集数据。例如,科学研究的数据是通过科学实验的各
                    种传感器采集,并传输到数据库管理系统中的。



                      5 . 2 . 2   数据的存储和保护




                         1.数据的存储

                         存储数据主要有两种方式,一种是把数据存在本地内部,另一种是把数据放在第三方
                                                                                                                    107107







            9      ֻ໴ᅣ JOEE
   110   111   112   113   114   115   116   117   118   119   120