网站与BS4刮:无法获取表(Web scraping with BS4: unable to get table)
当您在浏览器中打开下面的URL时,
你会看到一个名为“复制”的紫色图标。 当您选择此图标(“复制”)时,您将获得一个完整的表格,您可以将其粘贴到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,
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 ...