from bs4 import BeautifulSoup
import requests
from translate import Translator
import json
import re
def horoscope():your_birth_day = input("输入您的生日的日期> ")your_birth_month = input("输入你生日的月份> ")if (int(your_birth_month) == 12 and int(your_birth_day) >= 22) or (int(your_birth_month) == 1 and int(your_birth_day) <= 19):sign = 10elif (int(your_birth_month) == 1 and int(your_birth_day) >= 20) or (int(your_birth_month) == 2 and int(your_birth_day) <= 17):sign = 11elif (int(your_birth_month) == 2 and int(your_birth_day) >= 18) or (int(your_birth_month) == 3 and int(your_birth_day) <= 19):sign = 12elif (int(your_birth_month) == 3 and int(your_birth_day) >= 20) or (int(your_birth_month) == 4 and int(your_birth_day) <= 19):sign = 1elif (int(your_birth_month) == 4 and int(your_birth_day) >= 20) or (int(your_birth_month) == 5 and int(your_birth_day) <= 20):sign = 2elif (int(your_birth_month) == 5 and int(your_birth_day) >= 21) or (int(your_birth_month) == 6 and int(your_birth_day) <= 20):sign = 3elif (int(your_birth_month) == 6 and int(your_birth_day) >= 21) or (int(your_birth_month) == 7 and int(your_birth_day) <= 22):sign = 4elif (int(your_birth_month) == 7 and int(your_birth_day) >= 23) or (int(your_birth_month) == 8 and int(your_birth_day) <= 22):sign = 5elif (int(your_birth_month) == 8 and int(your_birth_day) >= 23) or (int(your_birth_month) == 9 and int(your_birth_day) <= 22):sign = 6elif (int(your_birth_month) == 9 and int(your_birth_day) >= 23) or (int(your_birth_month) == 10 and int(your_birth_day) <= 22):sign = 7elif (int(your_birth_month) == 10 and int(your_birth_day) >= 23) or (int(your_birth_month) == 11 and int(your_birth_day) <= 21):sign = 8elif (int(your_birth_month) == 11 and int(your_birth_day) >= 22) or (int(your_birth_month) == 12 and int(your_birth_day) <= 21):sign = 9day=input("如果想看今天就打today,明天就看tomorrow:")url = ("https://www.horoscope.com/us/horoscopes/general/"f"horoscope-general-daily-{day}.aspx?sign={sign}")  # 获取需要查询的星座的链接soup = BeautifulSoup(requests.get(url).content, "html.parser")a=soup.find("div", class_="main-horoscope").p.textreturn a
def translate(word):# 有道词典 apiurl = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=null'# 传输的参数,其中 i 为需要翻译的内容key = {'type': "AUTO",'i': word,"doctype": "json","version": "2.1","keyfrom": "fanyi.web","ue": "UTF-8","action": "FY_BY_CLICKBUTTON","typoResult": "true"}# key 这个字典为发送给有道词典服务器的内容response = requests.post(url, data=key)# 判断服务器是否相应成功if response.status_code == 200:# 然后相应的结果return response.textelse:print("有道词典调用失败")# 相应失败就返回空return None
def get_reuslt(repsonse):# 通过 json.loads 把返回的结果加载成 json 格式result = json.loads(repsonse)c=result['translateResult'][0][0]['tgt']return c
def main():a=horoscope()print(a)b = re.split('\.',a )s=[]for i in b:list_trans = translate(i)print(get_reuslt(list_trans))
if __name__ == '__main__':try:main()except:pass

星座运势预测,python爬虫相关推荐

  1. 好玩的API调用之---星座运势的API与爬虫爬取

    更多技术文章请访问我的个人博客http://www.rain1024.com 好玩的API调用之-星座运势API与爬虫 平时写程序经常需要用到一些服务,像翻译,天气预报,星座什么的,我一般都是用Pyt ...

  2. python运势预测程序_基于Python的星座运势接口调用代码实例

    [python]代码库#!/usr/bin/python # -*- coding: utf-8 -*- import json, urllib from urllib import urlencod ...

  3. python运势预测程序_星座运势查询示例代码

    #!/usr/bin/python # encoding:utf-8 import urllib2, json, urllib # 2.星座运势查询 data = {} data["appk ...

  4. 利用python实现星座运势查询APP

    利用python实现星座运势查询APP 学习交流,老鸟指导,直播学习可以进我的python学习交流群 # *_* coding:utf8 *_* import jsonimport requests ...

  5. Python:实现获取daily horoscope每日星座运势算法(附完整源码)

    Python:实现获取daily horoscope每日星座运势算法 import requests from bs4 import BeautifulSoupdef horoscope(zodiac ...

  6. Python编写每日星座运势获取算法

    Python编写每日星座运势获取算法 获取每日星座运势是许多人关注的一个话题.本文将介绍如何使用Python编写一个获取每日星座运势的程序,并附上完整的源代码. 首先,我们需要导入一些必要的库,包括r ...

  7. 抓取新浪的每日星座运势

    从新浪上抓取每日的星座运势,然后往求实的Astrology版发. #!/usr/bin/python # encoding: utf-8 from sgmllib import SGMLParser ...

  8. 2023最新在线星座运势网站开源源码+只作为参考

    正文: 在线星座运势网站开源源码这里,提供了各种星座的最新运势预测,让你知道自己今天的运势如如何,有兴趣的自行去安装体验吧. 程序: wwxsgr.lanzouj.com/i0MXy0mkdcng 图 ...

  9. 星座运势接口、星座查询接口和星座配对接口应用解决方案【源码可用】

    福利彩蛋:没有好玩的 API 接口?上百款免费接口等你来,免费 API,免费 API 大全 这里仅分享如何将多个相关接口整合成一个完整的产品解决方案 以将星座运势接口.星座查询接口和星座运势接口整合成 ...

最新文章

  1. eosjs-ecc中文文档
  2. (0089)iOS开发之iOS应用间相互跳转(URL Scheme)
  3. PHP文本处理 中文汉字字符串 转换为数组
  4. ISP、主机之间的通信方式、电路交换和分组交换、时延
  5. #1398 : 网络流五·最大权闭合子图
  6. 三菱fx3uplc恢复出厂设置_三菱fx3uplc解密过程与步骤分享
  7. linux rpm安装软件笔记
  8. golang基本语法——变量使用详解
  9. 淘宝前端框架kissyui
  10. 姆町网络验证带壳内存取密钥
  11. Linux 网络编程 TCP/UDP编程
  12. 《App后台开发运维和架构实践》推荐序
  13. Hi3516A开发--电阻分压阻值计算
  14. 博图advanced关于vb自动弹出画面
  15. 微信开发者工具之页面跳转
  16. 新《古惑仔》 —— 神转折大赛
  17. 【Task02】Numpy组队学习—随机抽样
  18. IIS:System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”类型的权限已失败。
  19. 使用Nodejs搭建一个简易的留言簿(完结)
  20. layui复选框默认选中

热门文章

  1. java heap 参数_java heap space解决方法和JVM参数设置--- JVM参数设置和程序优化篇
  2. ubuntu安装cad快速看图linux版
  3. 限制p元素之显示2行文字,同时出现省略号。
  4. OpenCV学习笔记5
  5. 双离合档把上按钮作用_双离合怎么换挡图解,7速双离合档位示意图
  6. 短信设备常用AT指令集
  7. [练习]QQ/微信 表情收藏-测试用例的编写 [简洁思路]
  8. PyEcharts 之旭日图
  9. WEB攻防-通用漏洞SQL读写注入ACCESS偏移注入MYSQLMSSQLPostgreSQL
  10. 记一次Y7000P内存升级(骇客神条套条),让电脑飞起来~