小编jat*_*ani的帖子

Gdown 给出了特定文件的权限错误,尽管它手动打开得很好

我无法使用 gdown 包下载文件。它给出了权限错误。但是当我手动打开它时,它没有给出这样的错误并且打开正常。这是我正在使用的代码和链接

import gdown
url='https://drive.google.com/uc?id=0B1lRQVLFjBRNR3Jqam1menVtZnc'
output='letter.pdf'
gdown.download(url, output, quiet=False)
Run Code Online (Sandbox Code Playgroud)

错误是权限被拒绝:https://drive.google.com/uc? id=0B1lRQVLFjBRNR3Jqam1menVtZnc 也许您需要更改“知道链接的任何人”的权限?

python google-drive-api

29
推荐指数
3
解决办法
4万
查看次数

拓扑错误:无法执行操作“GEOSIntersection_r”

大家好,我正在尝试将选区形状文件映射到议会选区。我有[两者]的形状文件。基本上,我必须将人口普查数据中地区级别给出的所有变量映射到议会选区级别。所以我正在关注 pycon talk。一切工作正常,但我在 get_intersection 函数中遇到错误。错误是 TopologicalError: The operation 'GEOSIntersection_r' could not be performed. Likely cause is invalidity of the geometry <shapely.geometry.polygon.Polygon object at 0x7f460250ce10>

我尝试过使用 pygeos 和 rtree。有一些链接说问题出在 pygeos 中。所以,我使用了rtree。但没有用。请帮忙提前谢谢。

我尝试过的代码是

constituencies=gpd.GeoDataFrame.from_file('/content/AC_All_Final.shp')
districts=gpd.GeoDataFrame.from_file('/content/2001_Dist.shp')
districts['AREA'] = districts.geometry.area
constituencies['AREA'] = constituencies.geometry.area
merged = gpd.sjoin(districts, constituencies).reset_index().rename(
    columns={'index': 'index_left'})

def get_intersection(row):
    left_geom = districts['geometry'][row['index_left']]
    right_geom = constituencies['geometry'][row['index_right']]
    return left_geom.intersection(right_geom)

***Error is at this point***
merged['geometry'] = merged.apply(get_intersection, axis=1)
merged['AREA'] = merged.geometry.area
Run Code Online (Sandbox Code Playgroud)
Error trace is given below:
TopologyException: Input geom 1 is invalid: …
Run Code Online (Sandbox Code Playgroud)

python topology r-tree python-3.x geopandas

8
推荐指数
2
解决办法
1万
查看次数

使用 Python 和 Selenium 抓取时清空 pdf

我在尝试使用 Python 中的 Selenium 从网页打印 PDF 时遇到问题。有问题的网页是 https://jamabandi.nic.in/land%20records/NakalRecord。我尝试从每个下拉列表中选择第一条记录,然后单击“Nakal”按钮生成 PDF。

但是,即使网页上存在表格,生成的 PDF 始终为空。我尝试过手动打印到 PDF 操作和使用 Selenium 自动打印,但在这两种情况下,生成的 PDF 都是空的。

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service()
options = webdriver.ChromeOptions()
# Set up preferences for printing to PDF
settings = {
    "recentDestinations": [{"id": "Save as PDF", "origin": "local", "account": ""}],
    "selectedDestinationId": "Save as PDF",
    "version": 2
}
prefs = {
    'printing.print_preview_sticky_settings.appState': json.dumps(settings),
    'printing.print_to_file': True,
    'printing.print_to_file.path': '/Users/jatin/Downloads/output.pdf'  # Specify the desired output path
}
chrome_options.add_experimental_option('prefs', prefs)

import urllib.request …
Run Code Online (Sandbox Code Playgroud)

python webdriver web-scraping pandas selenium-chromedriver

1
推荐指数
1
解决办法
329
查看次数