首页 \ 问答 \ 网站与BS4刮:无法获取表(Web scraping with BS4: unable to get table)

网站与BS4刮:无法获取表(Web scraping with BS4: unable to get table)

当您在浏览器中打开下面的URL时,

http://www.kianfunds2.com/%D8%A7%D8%B1%D8%B2%D8%B4-%D8%AF%D8%A7%D8%B1%D8%A7%DB%8C%DB% 8C-%D9%87%D8%A7-%D9%88-%D8%AA%D8%B9%D8%AF%D8%A7%D8%AF-%D9%88%D8%A7%D8%AD% D8%AF-%D9%87%D8%A7

你会看到一个名为“复制”的紫色图标。 当您选择此图标(“复制”)时,您将获得一个完整的表格,您可以将其粘贴到Excel中。 我怎样才能得到这个表作为Python中的输入?

我的代码在下面,它什么也没有显示:

import requests
from bs4 import BeautifulSoup
url = "http://www.kianfunds2.com/" + "ارزش-دارایی-ها-و-تعداد-واحد-ها"
result = requests.get(url)
soup = BeautifulSoup(result.content, "html.parser")
table = soup.find("a", class_="dt-button buttons-copy buttons-html5")

我不想使用Selenium,因为它需要很长时间。 请使用美丽的汤。


When you open the URL below in a browser,

http://www.kianfunds2.com/%D8%A7%D8%B1%D8%B2%D8%B4-%D8%AF%D8%A7%D8%B1%D8%A7%DB%8C%DB%8C-%D9%87%D8%A7-%D9%88-%D8%AA%D8%B9%D8%AF%D8%A7%D8%AF-%D9%88%D8%A7%D8%AD%D8%AF-%D9%87%D8%A7

you see a purple icon by the name of "copy". When you select this icon("copy"), you will achieve a complete table that you can paste into Excel. How can I get this table as an input in Python?

My code is below, and it shows nothing:

import requests
from bs4 import BeautifulSoup
url = "http://www.kianfunds2.com/" + "ارزش-دارایی-ها-و-تعداد-واحد-ها"
result = requests.get(url)
soup = BeautifulSoup(result.content, "html.parser")
table = soup.find("a", class_="dt-button buttons-copy buttons-html5")

I don't want use Selenium, because it takes a lot of time. Please use Beautiful Soup.


原文:https://stackoverflow.com/questions/49362391
更新时间:2022-01-12 12:01

相关问答

更多
  • 您的列和行是相反的。 选择图表后,请转到“设计”上下文选项卡,然后单击“切换行/列”。 这样可以解决吗? 如果是,您可以使用: ActiveChart.PlotBy = xlRows or ActiveChart.PlotBy = xlColumns 以编程方式进行。 Your columns and rows are reversed. When you have the chart selected go und "Design" contextual tab and click "Switch ...
  • 尝试迭代系列集合并逐个设置名称。 像这样的东西: foreach (Series series in myChart.SeriesCollection()){ series.Name = "MyName"; } Try to iterate over series collection and set the names one by one. Something like this: foreach (Series series in myChart.SeriesCollection()){ ...
  • 也许不理想,但它的确有效。 只需从数据源中删除图例标签,然后在其格式符合您喜欢的位置插入 - > shape - >文本框。 我想你想要的附图示例。 **免责声明:此图表绝对没有任何意义。 Maybe not ideal, but it works. Just delete the legend label from your data source and then insert -> shape -> text box in its place that is formatted to your lik ...
  • 要在Excel中选择活动图表,可以使用此代码 Excel.ChartObject chartObject11 = (Excel.ChartObject)Ws.ChartObjects(1); chartObject11.Activate(); 基于此可以编辑图表并格式化它。就像更改其数据范围或格式化其颜色或高度或宽度等。 希望这可以帮助 To select an active chart in excel one can use this code Excel.ChartObject chartObjec ...
  • 您可以使用item1.ImageStyle = LegendImageStyle.Line来创建实线。 更多信息在这里 然而,据我所知,没有“破折号”风格,但可以使用图像作为符号。 所以你可以尝试制作一个虚线的小图像并阅读它 。 我希望它有所帮助。 You can use item1.ImageStyle = LegendImageStyle.Line to create a solid line. More info here However there is no "dash" style as far ...
  • 在调用xlCharts.Add(10, 80,500,200) , 10,80是相对于A1单元的点的期望位置的坐标。 In the call xlCharts.Add(10, 80,500,200), 10,80 are the coordinates of the desired position in points, relative to A1 cell.
  • 最后找到了答案......在这里发布代码,以便对其他人有所帮助。 private void HeapStatsChart_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { HitTestResult result = HeapStatsChart.HitTest(e.X, e.Y); if (result != null && result.Object != n ...
  • 通过假设你想要我通过评论建议的东西,而不在其余的代码中详细说明(只是快速建议:更好地删除GC部分); 这就是你所追求的: axis = (Axis)chartPage.Axes(XlAxisType.xlCategory); axis.MajorTickMark = XlTickMark.xlTickMarkNone; axis.Format.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse; 此代码指的是X轴:第二行删除主刻度线(图中显示 ...
  • 我的问题是Excel中的Chart对象实际上是图表工作表,而图表本身是ChartObject对象,并且您使用它所在的Shape对象来处理它。 这是一个链接 , 另一个关于它的abit,以及来自这个MS链接的一些VBA代码显示了一点,请注意有几种不同的方法来完成它: Sub AddChart_Excel() Dim objShape As Shape ' Create a chart and return a Shape object reference. ' The Shap ...
  • 尝试这个: var chart = chartObj.Chart as Excel.Chart; var s = chart.SeriesCollection(1) as Excel.Series; var xValues = (s.XValues as object) as Array; foreach (var xVal in xValues) { MessageBox.Show(xVal.ToString()); } 还有什么是我用COM互操作得到的`Object [*]`类型? Try ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)