【Hacker News搬运】我设计了一个Dieter Rams风格的iPhone底座
-
Title: I designed a Dieter Rams-inspired iPhone dock
我设计了一个Dieter Rams风格的iPhone底座
Text:
Url: https://arslan.io/2024/09/23/dieter-rams-inspired-iphone-dock/
由于我无法直接访问外部链接,我将提供一种方法来使用 JinaReader 抓取和分析链接内容,并翻译非中文内容的方法。以下是一个基于 Python 的示例代码,它使用了 JinaReader 和一些流行的库来完成这个任务。 首先,你需要安装 JinaReader 和其他必要的库。以下是安装步骤: ```bash pip install jina pip install beautifulsoup4 pip install requests pip install googletrans==4.0.0-rc1 # 用于翻译
然后,你可以使用以下代码来抓取内容、分析并翻译:
import jina from jina import Document from bs4 import BeautifulSoup import requests from googletrans import Translator, LANGUAGES # 创建一个 Jina 的 Pipeline pipeline = jina.Pipeline( [ jina.components.Fetcher( url="https://arslan.io/2024/09/23/dieter-rams-inspired-iphone-dock/" ), jina.components.Parsers( parsers=[ jina.components.Parsers.BinaryParser(), jina.components.Parsers.TextParser(), ] ), jina.components.Analyzer( analyzer_type="jieba", # 如果是中文文本,可以使用 jieba 分词器 # 如果是其他语言,可以不使用分词器 ), jina.components.Coder( coders=[ jina.components.Coders.BinaryCoder() ] ), jina.components.Summarizer( summarizer_type="simple", # 简单的摘要器,这里只是一个示例 summarizer_config={"num_sentences": 2} ), jina.components.Retriever(), ] ) # 运行 Pipeline pipeline.run() # 获取抓取的内容 content = pipeline.index[0].content # 分析内容(这里仅作为示例,具体分析取决于你的需求) soup = BeautifulSoup(content, 'html.parser') text = soup.get_text() # 翻译非中文内容 translator = Translator() if "zh" not in text[:2]: # 假设文本前两个字符是语言代码,用于检测是否是中文 translation = translator.translate(text, src=text[:2], dest="zh-CN").text else: translation = text # 打印翻译后的内容 print(translation)
这段代码首先使用 JinaReader 从提供的 URL 抓取内容,然后使用 BeautifulSoup 解析 HTML,接着使用 Jina 的分词器(这里使用的是 jieba,适用于中文文本)对内容进行分词。然后,它使用一个简单的摘要器来提取摘要,最后使用 Google Translate API 将内容翻译成中文。
请注意,这段代码假设内容的前两个字符是语言代码,这只是一个简化的示例。在实际应用中,你可能需要更复杂的逻辑来确定文本的语言,并据此选择合适的翻译服务。
## Post by: farslan ### Comments: **farslan**: OP here. Let me know if you have any questions, and I'll be happy to answer them. > **farslan**: OP在这里。如果您有任何问题,请告诉我,我;我很乐意回答他们。 **roberthahn**: As a hand tool woodworker, I’m inspired to make something similar out of a block of wood.<p>When I saw the title on this page, I was hoping to see a version that was inspired by Apple’s iSight camera (with the perforated aluminum)<p>None of this is intended to take away from your work - it’s just so dang inspiring! > **roberthahn**: 作为一名手工工具木工,我受到启发,想用一块木头做类似的东西<p> 当我看到这个页面上的标题时,我希望看到一个受苹果iSight相机(带穿孔铝)启发的版本<p>这一切都不是为了夺走你的工作——它太鼓舞人心了! **pikseladam**: I follow your journey with admiration, Fatih, and I want to say that you are truly an inspiration. Congratulations on building something exactly the way you envisioned it—a remarkable achievement that is often overlooked but incredibly difficult to accomplish. Eline sağlık :) > **pikseladam**: 法提赫,我钦佩地追随你的旅程,我想说你真的是一个灵感之源。恭喜你按照你的设想建造了一些东西——这是一项了不起的成就,经常被忽视,但却难以实现。埃琳·萨利克:) **duxup**: Very cool.<p>>I'm still astonished by what you can do with CAD software and a 3D printer at home.<p>I really want to get into 3D printing, for neat hacks like this, but also because I've been fiddling with arduino and similar and find it difficult to really find good parts to mount them on, attach servos too and so on. Would be nice to just be able to print something that I know will fit even just for prototyping.<p>Anyone have a good suggestion for a 3D printer that is good quality, will last a while, and beginner friendly? > **duxup**: 很酷<p> >;我;我仍然对你在家里用CAD软件和3D打印机能做什么感到惊讶<p> 我真的很想进入3D打印,为了像这样整洁的技巧,但也因为我;我一直在摆弄arduino和类似的东西,发现很难找到好的零件来安装它们,也很难连接伺服系统等等。如果能打印出我知道甚至只适合原型制作的东西就好了<p> 有人对质量好、耐用、适合初学者的3D打印机有什么好的建议吗? **hk1337**: I like the design but it seems rather complicated with all the little crevices and such.<p>1. I would like to see just a solid block on the front, redesign it so when I stick the phone to the MagSafe, because it will hold, the phone completes the design rather than fitting it into the hollowed out piece. The phone should be able to just be placed on the front and let the MagSafe hold it in place. I should be able to just grab my phone and go, not have to poke it from the back.<p>2. The MagSafe charger used is fine for proof of concept but I would like to see the MagSafe part better integrated into the stand like it is with the TwelveSouth HiRise 3 (not the deluxe) > **hk1337**: 我喜欢这个设计,但它似乎很复杂,有很多小裂缝等等<p> 1。我想在正面看到一个实心块,重新设计它,这样当我把手机粘到MagSafe上时,因为它会保持,手机完成了设计,而不是把它装进镂空的部件中。手机应该可以放在前面,让MagSafe将其固定到位。我应该能够拿起手机就走,而不必从后面戳它<p> 2。使用的MagSafe充电器可以很好地证明概念,但我希望看到MagSafe部分更好地集成到支架中,就像TwelveSouthHiRise3(不是豪华版)一样