SkillAgentSearch skills...

Xueqiu

a humanize XueQiu API wrappers.

Install / Use

/learn @1dot75cm/Xueqiu
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

xueqiu

a humanize XueQiu API wrappers.

Installation

1.First, you need to install some basic components.

2.And then, install Google Chrome Browser and Chrome Driver.

> copy chromedriver.exe %LOCALAPPDATA%\Programs\Python\Python37-32\

3.Finally, install xueqiu via pip.

$ pip install xueqiu  # OR git+https://github.com/1dot75cm/xueqiu@master
$ pip install git+https://github.com/1dot75cm/browsercookie@master
$ python3 -m xueqiu
xueqiu x.y.z - A humanize XueQiu API wrappers.

:copyright: (c) 2019 by 1dot75cm.
:license: MIT, see LICENSE for more details.

enjoy!!!

Quick start

Example:

>>> news = xueqiu.news()  # watch the news
>>> news
{'list': [<xueqiu.Post 为何价值投资长期有效[https://xueqiu.com/8291461932/120351059]>,
  <xueqiu.Post 韬蕴资本CEO温晓东怒斥贾跃亭:怎就一个[https://xueqiu.com/2095268812/120483699]>,
  <xueqiu.Post 增持与回购20190122-201901[https://xueqiu.com/9206540776/120458648]>,
  <xueqiu.Post 医药研发外包为什么这么红?(上)[https://xueqiu.com/1472391509/120481662]>,
  <xueqiu.Post 医药大赛道之大分子生物药(下)[https://xueqiu.com/1472391509/120482094]>,
  <xueqiu.Post 增强型指数基金,到底“强”在哪里?[https://xueqiu.com/8082119199/120480761]>,
  <xueqiu.Post 价值投资不需要概率思维吗?—与董宝珍先生[https://xueqiu.com/3555476733/120245234]>,
  <xueqiu.Post 邓晓峰的投资观[https://xueqiu.com/7649503965/120430145]>,
  <xueqiu.Post 复利无敌:买入一只股票看这四点[https://xueqiu.com/1876906471/120479202]>,
  <xueqiu.Post 再论安全边际[https://xueqiu.com/4465952737/120453192]>],
 'next_max_id': 20323343}
>>> p = news['list'][0]
>>> "{} {} 赞{} 评论{} 转发{} {}".format(p.title, p.user.name, p.like_count,
                                        p.reply_count, p.retweet_count, p.target)
'为何价值投资长期有效 房杨凯的投资世界 赞9 评论11 转发9 https://xueqiu.com/8291461932/120351059'
>>> p.user.get_posts()  # get user's article
>>> p.user.posts
{'count': 622,
 'page': 1,
 'maxpage': 63,
 'list': [<xueqiu.Post [https://xueqiu.com/8291461932/120497097]>,
  <xueqiu.Post [https://xueqiu.com/8291461932/120491351]>,
  <xueqiu.Post [https://xueqiu.com/8291461932/120487476]>,
  <xueqiu.Post [https://xueqiu.com/8291461932/120487448]>,
  <xueqiu.Post [https://xueqiu.com/8291461932/120486037]>,
  <xueqiu.Post 腾讯游戏帝国的护城河还在吗?[https://xueqiu.com/8291461932/120485596]>,
  <xueqiu.Post [https://xueqiu.com/8291461932/120473933]>,
  <xueqiu.Post [https://xueqiu.com/8291461932/120434054]>,
  <xueqiu.Post [https://xueqiu.com/8291461932/120434037]>,
  <xueqiu.Post [https://xueqiu.com/8291461932/120434020]>]}
>>> p.user.posts['list'][0].text  # content
'回复@A8天道酬勤: 这个问题应该放在买之前。//@A8天道酬勤:回复@房杨凯的投资世界:假如花旗银行做假账,聂夫还会不会持有?'
>>> p.user.posts['list'][0].like()  # like this (need login)

API

User class

A user class that contains user-related methods.

User object attributes:

  • id - user id.
  • profile - user's profile url.
  • name - user name.
  • city - city, for example '上海'.
  • description - user description.
  • friends_count - the number of user's friends.
  • followers_count - the number of user's fans.
  • posts_count - the number of user's post.
  • stocks_count - the number of stocks.
  • friends - use to save User object for friends.
  • followers - use the save User object for fans.
  • posts - use the save Post object for post.
  • articles - use the save Post object for user's article.
  • favorites - use the save Post object for favorite articles.
  • stocks - use the save Stock object for favorite stocks.
  • hot_stocks - use the save Stock object for the current hot stocks.

User object methods:

  • get_friends(page: int = 1) - get your friends and save to self.friends.

  • get_followers(page: int = 1) - get your fans and save to self.followers.

  • get_posts(page: int = 1, count: int = 10) - get your posts and save to self.posts.

  • get_articles(page: int = 1, count: int = 10) - get your articles and save to self.articles.

  • get_favorites(page: int = 1, count: int = 20) - get your favorite posts and save to self.favorites.

  • get_stocks(mkt: int = 1, count: int = 1000) - get your stocks and save to self.stocks.

  • get_hot_stocks(mkt: int = 10, time_range: str = "hour", count: int = 10) - get hottest stocks.

    • :param mkt: (optional) market type, default is 10.
      • value: 全球10 沪深12 港股13 美股11
    • :param time_range: (optional) hottest stocks by time range, default is hour.
      • value: hour, day
    • :param count: (optional) the number of results, default is 10.
  • send_verification_code(phone: int) - send verification code to your phone. Note: only 5 times a day.

  • login(uid: str = '', passwd: str = '', login_type: str = 'phone') - user login by password or verification code. If the cookie cache exists, load it first and return. Otherwise, login and save the cookie to file (Linux ~/.xueqiu/cookie or Windows).

    • :param uid: your username or phone number.
    • :param passwd: your password or verification code.
    • :param login_type: (optional) login type, default is phone.
      • value: password, phone
  • load_cookie() - load cookies from local file or browser(chrome or firefox). You can login your account on the chrome browser, then execute load_cookie(), and now login successfully.

Example:

>>> u = User(2478797769)
>>> u.name
"红利基金"
>>> u.get_posts()
>>> u.posts['list'][0].title
'【你了解红利基金吗】红利基金(501029)热问快答!(12.31)'
>>> u.get_favorites()
>>> u.favorites['list'][0].title
'2018年A股大数据盘点:30张图尽览市场热点'

Post class

A post class that contains post-related methods.

Post object attributes:

  • id - post id.
  • user - post authors. a User class object.
  • created_at - created time. a Arrow class object.
  • target - post url.
  • view_count - view count.
  • reply_count - reply count.
  • retweet_count - retweet count.
  • fav_count - favorites count.
  • like_count - like count.
  • title - post title.
  • text - post content.
  • full_text - the full content of the article.
  • comments - use the save Comment object for post.

Post object methods:

  • get_content() - get article content and save to self.full_text.
  • get_comments(page: int = 1, count: int = 20, asc: str = 'false') - get article comments and save to self.comments.
  • like() - like the article. (require login)
  • unlike() - unlike the article. (require login)
  • favorite() - favorite the article. (require login)
  • unfavorite() - unfavorite the article. (require login)

Example:

>>> p = Post('2478797769/78869335')
>>> p.user.name
"红利基金"
>>> p.created_at.format("YYYY-MM-DD")
"2016-12-13"
>>> p.title
'【你了解红利基金吗】红利基金(501029)热问快答!(12.31)'
>>> p.target
"https://xueqiu.com/2478797769/78869335"
>>> p.get_content()
>>> p.full_text
'目录:\n一、\n华宝标普中国A股红利机会指数证券投资基金\n......'
>>> p.get_comments()
>>> p.comments['list'][-1].text
'为什么成份股中有很多次新股?百思不得其解'

Comment class

A comment class that contains comment-related methods.

Comment object attributes:

  • id - comment id.
  • user - comment authors. a User class object.
  • post - comment on an article. a Post class object.
  • created_at - created time. a Arrow class object.
  • like_count - like count.
  • text - comment content.

Comment object methods:

  • like() - like the comment. (require login)
  • unlike() - unlike the comment. (require login)

Example:

>>> p = Post('2478797769/78869335')
>>> p.get_comments()
>>> c = p.comments['list'][0]
>>> c.user.name
'红利基金'
>>> c.text
'回复@孙浩云: 怎么可能....2018年跌幅为24.54%,较主流指数跌幅较小。不知道您50%多是哪儿看来的呢'

Selector class

The Selector class implements a stock filter.

Selector object attributes:

  • market - market string, default is SH.
    • value: SH, HK, US
  • queries - include default parameters with selector.

Selector object methods:

  • url() - return a selector url string.
  • help(range: str = "base", show: str = "text") - show selector parameters.
    • :param range: (optional) parameters range, default is base. value:
      • SH: industries, areas, base, ball, quota, finan_rate, stock_data, profit_sheet, balance_sheet, cash_sheet
      • HK: industries, base, ball, quota
      • US: industries, base, ball, quota, grow, profit_sheet, balance_sheet, cash_sheet
    • :param show: (optional) output help or return generator, default is text.
      • value: text, keys
  • scope(exchange: str = '', indcode: str = '', areacode: str = '') - set stock selector scope.
    • :param exchange: (optional) set A-share exchange market, default is None.
      • value: SH, SZ or None
    • :param indcode: (optional) set industry code, default is None. please see self.help('industries')
    • :param areacode: (optional) set area code, default is None. please see self.help('areas')
  • param(*args, **kwargs) - set stock selector paramters.
    • :param *args: (optional) set parameters key, default value is ALL. for example, the self.param('pb', 'mc') will be set pb=ALL&mc=ALL params.
    • :param **kwargs: (optional) set parameters key and value. for example, the self.param('pettm'=0_30) will be set pettm=0_30 param.
  • orderby(key: str = 'symbol') - stock selector results are sorted by field.
    • :param key: the results are sorted by the key, default is symbol. the key parameters can be viewed through self.help('base').
  • order(ord: str = 'desc') - set stock selector results are sorted.
    • :param ord: the ascending and descending order, default is desc.
      • value: asc, desc
  • page(page: int = 1) - set stock selector results page number.
  • count(size: int = 10) - the number of stock selector results.
  • run() - sends a stoc

Related Skills

View on GitHub
GitHub Stars46
CategoryDevelopment
Updated2mo ago
Forks22

Languages

Python

Security Score

90/100

Audited on Feb 4, 2026

No findings