duancanjiu3754 2013-07-25 13:43
浏览 30
已采纳

如何只将新推文/ Instagram照片保存到数据库?

I'm building a two cron-jobs that regularly searches new tweets and instagram photos(and potentially more services) based on a tag.

The content is saved to a database and are later outputted to a webpage. This allows for faster loading and more importantly the ability to remove certain tweets so they are not displayed.

I want to make sure that no posts are saved twice in the database and am not sure what approach is best. Here are some options I consider:

  • I use Laravel and has the ability to demand the postID to be unique, this would make the database refuse when I try to save already existing posts. This might render unnesseary sql-queries though.
  • I could check the database for the latest saved post ID and stop the loop once I get to that post.
  • Atleast in twitter, I can pass the parameter since_id, wich allows me to just get the latest posts. However I haven't found the same parameter in instagram and it wouldn't work for html-scraping either.
  • 写回答

2条回答 默认 最新

  • dongyongkui6329 2013-07-25 14:02
    关注

    Twitter provides the 'created_at' value, giving you a date and time the tweet was created.

    Each time your cron job runs, store the date and time, then on the next run, only upload the tweet if the date/time is prior to the value of 'created_at'.

    I'm not too familiar with Instagram, sorry - but I assume the same logic would apply.

    ["created_at":"Wed Aug 27 13:08:45 +0000 2008"][1]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?